• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Diff between Hinernate Template and HibernateDAOSupport ?

 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what the the basic difference between the two !

 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic