If I\'m using an ORM like JPA2 - where I have my entities that are mapped to my database, should I still be using a DAO? It seems like a lot more overhead.
For examp
For the record.
For Single responsibility principle (SRP), DAO is a must have, it separates the model and logic in a persistence layer that can be easily portable.
If a project is using Test Unit then DAO helps to test it correctly (mockup, database testing and so on).
DAO is a SERVICE and like one, we could wrap our process in a nicely class that is easy to maintenance.
JPA reduces the number of lines of codes but, nothing more, the old rules still applies.
JPA brings a repository layer but its not OUR repository layer. In the same principle, let's say that we encapsulated a logic that obtain the profit of some process. May be the encapsulation is simply a multiplication for 0.1 but its still worthy to encapsulate.
For example, let's say that i have the next problem : for some odd reason, i can insert a new Client in the database?. Where should i start to test?. a: ClientDao if exists, if not, then good luck finding elsewhere.