|
From: Raj P. <coo...@gm...> - 2005-06-29 17:27:34
|
Hibernate 3.0 has improved support for session management, including automatic session management/flushing in transactions: http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuratio= n.html#configuration-j2ee-currentsession Have you guys thought about letting hibernate manage this instead of having extra code in Spring to manage this? Raj |
|
From: Juergen H. <ju...@in...> - 2005-06-29 22:30:06
|
Hibernate 3.0.1+'s management of Sessions indeed provides a couple of services: All it does is optionally flush and close each opened = Hibernate Session at the end of the transaction (potentially multiple Sessions per transaction), and optionally manage one single "contextual" Hibernate Session per transaction (also with flushing at transaction commit). Both = of these features are just supported for JTA / EJB CMT transactions. Spring goes beyond what Hibernate provides: * Hibernate Sessions can be consistently synchronized with any kind of Spring-managed transaction, whether a local JDBC transaction or a global = JTA transaction. (Furthermore, synchronization will also work with plain JTA transactions.) Spring's synchronization code will automatically adapt to = the environment, without your data access code having to change. * Spring's snchronization facility can optionally manage one Hibernate Session per HTTP request, letting transactions participate in it (OpenSessionInViewFilter / OpenSessionInViewInterceptor in "single = session" mode). This does not affect your DAO implementations either, working as transparently as possible. * Spring supports finer-grained transaction semantics such as a = read-only optimization: Read-only transactions will use a single Session per transaction, but _not_ attempt to flush it at transaction commit = (avoiding the unnecessary effort of looking for changes in persistent objects). = This is an important optimization that Spring has been providing for years. Hence, we will keep our current synchronization mechanism. This is an internal decision: It simply means that Spring will not use Hibernate3's built-in mechanism, which should not affect your application code in any way. As a side note, Spring does support Hibernate3's "SessionFactory.getCurrentSession()" method: When you run within a Spring-managed transaction (any kind: local or global), that method will return the current Spring-managed transactional Session. This allows for = DAO implementations that access Spring-managed Sessions without any Spring = API dependencies, coded against Hibernate3's native Session access API. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...] On Behalf = Of Raj Patel Sent: Wednesday, June 29, 2005 7:27 PM To: spr...@li... Subject: [Springframework-developer] Hibernate Session Management Hibernate 3.0 has improved support for session management, including automatic session management/flushing in transactions: http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configurat= ion .html#configuration-j2ee-currentsession Have you guys thought about letting hibernate manage this instead of = having extra code in Spring to manage this? Raj ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies = from IBM. Find simple to follow Roadmaps, straightforward articles, = informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Raj P. <coo...@gm...> - 2005-06-30 00:17:06
|
Thansk for the justification! On 6/29/05, Juergen Hoeller <ju...@in...> wrote: > Hibernate 3.0.1+'s management of Sessions indeed provides a couple of > services: All it does is optionally flush and close each opened Hibernate > Session at the end of the transaction (potentially multiple Sessions per > transaction), and optionally manage one single "contextual" Hibernate > Session per transaction (also with flushing at transaction commit). Both = of > these features are just supported for JTA / EJB CMT transactions. >=20 > Spring goes beyond what Hibernate provides: >=20 > * Hibernate Sessions can be consistently synchronized with any kind of > Spring-managed transaction, whether a local JDBC transaction or a global = JTA > transaction. (Furthermore, synchronization will also work with plain JTA > transactions.) Spring's synchronization code will automatically adapt to = the > environment, without your data access code having to change. >=20 > * Spring's snchronization facility can optionally manage one Hibernate > Session per HTTP request, letting transactions participate in it > (OpenSessionInViewFilter / OpenSessionInViewInterceptor in "single sessio= n" > mode). This does not affect your DAO implementations either, working as > transparently as possible. >=20 > * Spring supports finer-grained transaction semantics such as a read-only > optimization: Read-only transactions will use a single Session per > transaction, but _not_ attempt to flush it at transaction commit (avoidin= g > the unnecessary effort of looking for changes in persistent objects). Thi= s > is an important optimization that Spring has been providing for years. >=20 > Hence, we will keep our current synchronization mechanism. This is an > internal decision: It simply means that Spring will not use Hibernate3's > built-in mechanism, which should not affect your application code in any > way. >=20 > As a side note, Spring does support Hibernate3's > "SessionFactory.getCurrentSession()" method: When you run within a > Spring-managed transaction (any kind: local or global), that method will > return the current Spring-managed transactional Session. This allows for = DAO > implementations that access Spring-managed Sessions without any Spring AP= I > dependencies, coded against Hibernate3's native Session access API. >=20 > Juergen >=20 >=20 > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On Behalf = Of > Raj Patel > Sent: Wednesday, June 29, 2005 7:27 PM > To: spr...@li... > Subject: [Springframework-developer] Hibernate Session Management >=20 > Hibernate 3.0 has improved support for session management, including > automatic session management/flushing in transactions: >=20 > http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configurat= ion > .html#configuration-j2ee-currentsession >=20 > Have you guys thought about letting hibernate manage this instead of havi= ng > extra code in Spring to manage this? >=20 > Raj >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies fr= om > IBM. Find simple to follow Roadmaps, straightforward articles, informativ= e > Webcasts and more! Get everything you need to get up to speed, fast. > http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer >=20 >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&opclick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |