You make some points. But I nevertheless use a Dao layer, here’s why:
-
Database accesses are calls to a remote system. In all such cases (also web-service, ajax etc…), the granularity of interaction need to be big enough. Many tiny calls would kill performance. This performance necessity requires often a different view of the system, or layer (here, the Dao layer).
-
Sometimes, your persistence operation is only to load/save/delete an object. One unique Dao (or a superclass ; consider Generics) can be responsible for this, so you don’t have to code these methods again and again.
But often, you also have specific needs, like running a specific request that is not automatically created by the ORM. There, you code your specific need with a specific Dao method (reuse is often possible).
Having regular and specific needs in the same layer allow for reuse (for example, interception can ensure that a database connection is open/commited when needed).