Win a copy of The Business Blockchain this week in the Cloud 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic