Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why is hibernate with spring also used without utilizing hibernate template feature.

 
Monica Shiralkar
Ranch Hand
Posts: 826
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
spring provides hibernate template but i have seen code where spring is used with hibernate but without utilizing hibernate template feature.Is there some reason that sometimes we should use hibernate with spring but not using hibernate template.?

thanks.
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

This link gives the following explanation:

LocalSessionFactoryBean is the preferred way of obtaining a reference to a specific Hibernate SessionFactory, at least in a non-EJB environment. The Spring application context will manage its lifecycle, initializing and shutting down the factory as part of the application.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Monica. Shiralkar wrote:spring provides hibernate template but i have seen code where spring is used with hibernate but without utilizing hibernate template feature.Is there some reason that sometimes we should use hibernate with spring but not using hibernate template.?

thanks.


If you are using Hibernate but older versions than 3.1, then the template was helpful because it would hide boiler plate Hibernate code.

Since 3.1 Hibernate no longer has any boilerplate code or checked Exceptions, so if you are using Hibernate 3.1 you will get no benefit using the template in Spring.

Mark
 
Monica Shiralkar
Ranch Hand
Posts: 826
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic