|
From: Matthew E. P. <ma...@me...> - 2003-12-09 13:35:12
|
Juergen: FWIW: I am using the OpenSessionInViewFilter with Webwork2. Anyways, when the filter is applied, flushing never happens even when = =20 using the transactionproxy factory. If I remove the filter from the =20 web.xml, everything works perfectly. Any guesses? Cheers, matthew On Dec 9, 2003, at 7:03 AM, j=FCrgen h=F6ller [werk3AT] wrote: > Matthew, > > TransactionProxyFactoryBean can just be used to proxy Spring-managed =20= > Java objects: in the web case, at best a whole Controller. The view =20= > rendering is initiated by DispatcherServlet, delegating to =20 > View.render. There is no single entry point in form of a =20 > Spring-managed bean to catch the whole request processing. But there =20= > is the HandlerInterceptor facility to intercept that processing at =20 > various points. > > It's important to stress that OpenSessionInViewInterceptor for =20 > Spring's web MVC respectively OpenSessionInViewFilter for any web =20 > processing still lets Spring-managed business methods perform their =20= > transactions as usual. The interceptor/filter just pre-binds a =20 > Hibernate Session that all transactions will use to the current =20 > thread, and which will stay open until view rendering has been =20 > completed. > > Your TransactionProxyFactoryBean setup should work, with or without =20= > OpenSessionInViewFilter. Note that you need to access the "OSUserDao" =20= > bean to get transactional behavior, not the "OSUserDaoTarget" =20 > directly. And you need to get the method pattern in the =20 > transactionAttributes right - in the simplest case, specify: > > <property name=3D"transactionAttributes"> > <props> > <prop key=3D"*">PROPAGATION_REQUIRED</prop> > </props> > </property> > > That should open transactions for all methods, not just ones whose =20 > names start with "find" etc. And don't specify "readOnly" for =20 > transactions that should persist changes: "readOnly" will switch the =20= > underlying Hibernate Sessions to FLUSH_NEVER. A good way is to start =20= > with the general pattern above and go more fine-granular when you've =20= > managed to make the general case work. > > Juergen > > > -----Original Message----- > From: Matthew E. Porter [mailto:ma...@me...] > Sent: Tuesday, December 09, 2003 1:51 PM > To: j=FCrgen h=F6ller [werk3AT] > Subject: Re: [Springframework-developer] OpenSessionInViewFilter > > > Juergen: > Here is what I currently have that is not working. > > <bean id=3D"OSUserDaoTarget" > = class=3D"com.metissian.security.principal.provider.osuser.configuration.O=20= > S > UserManagerDAO"> > <property name=3D"sessionFactory"> > <ref local=3D"MetalSessionFactory"/> > </property> > </bean> > > <bean id=3D"OSUserDao" > = class=3D"org.springframework.transaction.interceptor.TransactionProxyFact=20= > o > ryBean"> > <property name=3D"transactionManager"> > <ref local=3D"MetalTransactionManager"/> > </property> > <property name=3D"target"> > <ref local=3D"OSUserDaoTarget"/> > </property> > <property name=3D"transactionAttributes"> > <props> > <prop = key=3D"find*">PROPAGATION_REQUIRED,readOnly</prop> > <prop key=3D"delete*">PROPAGATION_REQUIRED</prop> > <prop key=3D"update*">PROPAGATION_REQUIRED</prop> > <prop key=3D"save*">PROPAGATION_REQUIRED</prop> > </props> > </property> > </bean> > > > For some reason, I believed that wrapping an object in a > TransactionProxyFactoryBean provided the transactionality you talked > about. Am I wrong? > > > Cheers, > matthew > > On Dec 9, 2003, at 12:45 AM, j=FCrgen h=F6ller [werk3AT] wrote: > >> Matthew, >> >> You should either use Spring-managed transactions (via >> HibernateTransactionManager or JtaTransactionManager), which will >> automatically flush a Session at transaction commit, or set >> HibernateTemplate's/HibernateInterceptor's "flushMode" property to >> FLUSH_EAGER (respectively "flushModeName" to "FLUSH_EAGER" in a >> textual bean definition). This will guarantee to flush as early as >> possible, not after view rendering: After all, a view should not >> modify the model, so there should be no need to flush afterwards. >> >> Juergen >> >> >> ________________________________ >> >> Von: spr...@li... im Auftrag >> von Matthew E. Porter >> Gesendet: Di 09.12.2003 02:20 >> An: spr...@li... >> Betreff: [Springframework-developer] OpenSessionInViewFilter >> >> >> >> I am attempting to use the OpenSessionInViewFilter. According to the >> javadoc, the session is not flush at the end of the filter. =20 >> Therefore, >> without overriding the closeSession() method in the filter, how do I >> get the session to flush? I am currently accessing DAOs wrapped as a >> ProxyFactoryBean with a HibernateInterceptor. >> >> Please help! >> >> >> Cheers, >> matthew >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: IBM Linux Tutorials. >> Become an expert in LINUX or just sharpen your skills. Sign up for >> IBM's >> Free Linux Tutorials. Learn everything from the bash shell to sys >> admin. >> Click now! http://ads.osdn.com/?ad_id=3D1278&alloc_id=3D3371&op=3Dclick= >> _______________________________________________ >> Springframework-developer mailing list >> Spr...@li... >> = https://lists.sourceforge.net/lists/listinfo/springframework-developer >> >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: IBM Linux Tutorials. >> Become an expert in LINUX or just sharpen your skills. Sign up for >> IBM's >> Free Linux Tutorials. Learn everything from the bash shell to sys >> admin. >> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id371&op=3Dclick >> _______________________________________________ >> Springframework-developer mailing list >> Spr...@li... >> = https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for =20= > IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys =20 > admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id371&op=3Dclick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |