This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

query about hibernate methods

 
ravi pamuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Is it possible to write a single hibernate DAO class and getting the different table records by passing appropriate beans. The methods im using are saveOrUpdate(),delete(),executeQuery(). If anyone knows please let me know.

ThanksandRegards,
Ravi
 
Jason Ferguson
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ravi,

Absolutely. What you are looking for is the "Hibernate Generic DAO Pattern". In simple terms (leaving out the interfaces), I tend to create a class called "HibernateGenericDao" with the class declaration like this:



(Note: this class doesn't have to be abstract, thats just the way I do it).

This class tends to contain methods such as:



After this, I extend my entity-specific DAOs like this:



Does this help you out?

Jason


Originally posted by ravi pamuru:
Hi,

Is it possible to write a single hibernate DAO class and getting the different table records by passing appropriate beans. The methods im using are saveOrUpdate(),delete(),executeQuery(). If anyone knows please let me know.

ThanksandRegards,
Ravi

[ January 07, 2008: Message edited by: Jay Ferguson ]
 
ravi pamuru
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

Thanks for your reply. I will try it out and let you know the details later.

Thank&Regards,
Ravi
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!