GeeCON Prague 2014*
The moose likes Spring and the fly likes why is hibernate with spring also used without utilizing hibernate template feature. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Bookmark "why is hibernate with spring also used without utilizing hibernate template feature." Watch "why is hibernate with spring also used without utilizing hibernate template feature." New topic
Author

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

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 644
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 Levytskyi
Ranch Hand

Joined: Mar 29, 2012
Posts: 505
    
    1

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.


True person is moral, false is right!
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

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


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

Joined: Jul 07, 2012
Posts: 644
Thanks.
 
GeeCON Prague 2014
 
subject: why is hibernate with spring also used without utilizing hibernate template feature.