Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

DAO for joined tables  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hellow guys, I'm currently on learning using Dao pattern in my project. So as what I know, one Table is equivalent to one DAO, am I right? just like StudentDao, SubjectDao. Each dao performs crud operations in their associated tables. But my question is , how am I going to create a DAO for joined tables? lets say I have a query to join student and subject table, then how do I create a DAO for that? Should I place it to the StudentDao? or to SubjectDao? or there's a good practice in that kind of situation?

TIA!
 
Ranch Hand
Posts: 343
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you may want to read http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. If you still have more doubts than let us know.
 
Ranch Hand
Posts: 42
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Palak Mathur wrote:I think you may want to read http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. If you still have more doubts than let us know.


thanks for your help
and i have read that article but i have understood DAO design pattern but i did not get any help for DAO class for joined tables

please give me some more explanation
 
Ranch Hand
Posts: 65
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my take is it is really upto you on where to put such method, but you may want to consider cohesion, for example, if you are querying for the name of students that are enrolled to a specific subject then you may want to consider to put that in the SubjectDAO because your result makes sense to be coming from such class than from StudentDAO. Having the method name something like "getStudents(String subject)" will also help you decide. Hope this helps.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!