Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One big DAO or a DAO per entity?

 
Otis Onesh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sujeeth Pakala
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic