|
From: Norris, T. <tys...@be...> - 2004-06-22 22:27:35
|
Hi All -=20 I was re-reading this, and think it closely applies to a problem we are having with trying to implement an "OpenSessionInViewFilter" within weblogic. We would like to keep using JTATransactionManager, so that we can convert pieces of our CMT-EJB-centric application at a time. The problem for us is that the session is using a DataSource, and there will be 0..n transactions executed with "REQUIRES" propagation. Why is this a problem? Because once the transaction commits or rollsback, the DataSource connection (i.e. the session) it was using will become unusable, causing failures in any following data access. In our case weblogic enforces the invalidation of the connection (i.e. the session) after either commit or rollback. I think we could work around this by setting all methods that are "top level" access to "REQUIRES_NEW", so that their commit/rollback does not affect encompassing transactions.=20 I don't think the nested transaction support would help us, given that we want to retain (as much as possible) our current transaction interoperation, which will requires use of JTATransactionManager... Does this sound about right as far as the limit of our options? Thanks tyson -----Original Message----- From: Daniel Miller [mailto:mi...@pa...]=20 Sent: Sunday, June 13, 2004 8:29 PM To: spr...@li... Subject: RE: [Springframework-developer] Real OpenSessionInView (only in view) James, >Does that also mean that a new Hibernate session is created if a data access occurs after the exception? (Think of an app that logs application failures to a database.) No, that is the problem--the same session continues to be used after the exception occurs. >From the Hibernate Session interface javadoc: "If the Session throws an exception, the transaction must be rolled back and the session discarded. The internal state of the Session might not be consistent with the database after the exception occurs." http://www.hibernate.org/hib_docs/api/net/sf/hibernate/Session.html >Also, is the discarding (shutting down) of a session handled by the transaction manager or some other wrapper? I'm trying to understand if the discard behavior is the same for checked or unchecked exceptions. Our apps are set up to throw checked exceptions when we think the application could recover from the failure. No, discarding is not handled by the transaction manager. The session only needs to be discarded if a HibernateException is thrown (checked). If you use Spring's HibernateDAOSupport for your DAO's, Spring catches the HibernateExceptions and wraps them in DataAccessExceptions (unchecked). >In cases where a checked exception is deemed fatal we control rollback using: TransactionInterceptor.currentTransactionStatus().setRollbackOnly(); A rollback wouldn't solve the problem because you would still be using the same (potentially damaged) session for other data accesses after the exception occurred. > The Hibernate session will always get discarded properly, even when > exceptions get thrown during view rendering. If that doesn't happen in any > case, it's a bug in either Spring's interceptor/filter implementations (or > the servlet container's handling of filters, in case of > OpenSessionInViewFilter). > > Juergen Sorry Juergen, I worded my original message wrongly. The session is always properly discarded by Spring at the end of the request. Both the filter and the interceptor versions of OpenSessionInView do this correctly. However, they cannot tell when an exception is thrown in the middle of your business logic and therefore cannot discard the session and create a new one after an exception occurs. Daniel ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. >From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |