aspose file tools*
The moose likes Object Relational Mapping and the fly likes Diff between Hinernate Template and HibernateDAOSupport ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Diff between Hinernate Template and HibernateDAOSupport ?" Watch "Diff between Hinernate Template and HibernateDAOSupport ?" New topic
Author

Diff between Hinernate Template and HibernateDAOSupport ?

Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
what the the basic difference between the two !

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

DaoSupport gives you a HibernateTemplate.

While in essence both tie your code into Spring, DaoSupport because you extend the class couples your code to Spring more tightly. And you cannot extend any other class if you wanted to now.

If you are using Hibernate 3.x, I advise not to use either. Just inject your SessionFactory into your Repositories.
If you are using Hibernate 2.x, then 100% use the HibernateTemplate. Have it declared as a bean and inject the HibernateTemplate into your Repositories.

In any case of version, don't tightly couple your code to DaoSupport classes.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Prabhat Ranjan
Ranch Hand

Joined: Oct 04, 2006
Posts: 391
ok thanks !

means it the tightly coupling's nature that's why we do not use the HibernateTemplate in Hibernate 3.1x version ! right ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Prabhat Ranjan wrote:ok thanks !

means it the tightly coupling's nature that's why we do not use the HibernateTemplate in Hibernate 3.1x version ! right ?


The HibernateTemplate part isn't so much as coupling. But the benefits of single line to run a query, no need to Catch a checked Exception, beginning/commit/rollback of transactions that you get from the HibernateTemplate, you now automatically get in Hibernate anyway. HibernateException is not a checked Exception and you no longer begin/commit/rollback transactions in Hibernate 3.x version

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Diff between Hinernate Template and HibernateDAOSupport ?