This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes One big DAO or a DAO per entity? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "One big DAO or a DAO per entity?" Watch "One big DAO or a DAO per entity?" New topic
Author

One big DAO or a DAO per entity?

Otis Onesh
Greenhorn

Joined: Jul 04, 2013
Posts: 6
I have seen some discussions on the internet on this subject - most were 2-3 years old - and the results are inconclusive. Are there any suggestions on how to do it nowadays with jpa and all?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30136
    
150

Otis,
Welcome to CodeRanch!

I prefer to keep to one DAO per entity. Sometimes when the entities are closely related, I don't though. Or if I have reporting type queries that span a lot of tables.

In other words "it depends" which is why you aren't finding anything conclusive.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sujeeth Pakala
Ranch Hand

Joined: Mar 24, 2009
Posts: 94
Hello Otis,

To keep it simple : Use one DAO per entity.
To take advantage of Object oriented programming (ad to have fun !) : Generalise the CRUD ooperations using Abstraction. This way, your DAO class should be able to perform persistent opertaions on any type of entity

Good Luck !


Regards, Sujeeth Pakala
SCJP, SCWCD, SCBCD, ICAD, XML Master Basic, Certified SOA Professional
 
jQuery in Action, 2nd edition
 
subject: One big DAO or a DAO per entity?
 
Similar Threads
flow from JSP to DB
Thread problem
EJB with DB Access
Session Bean + DAO
def of DAO