I've added an OpenSessionInViewInterceptor (OSIVI) to my code to allow my JSPs to access lazily loaded associations. I already had a transaction manager setup and my services make use of the @Transactional annotation. This still works well for reading but writing only works in non request code, e.g. bean initialisation code - unless I set the flush mode name to FLUSH_AUTO.
I understand that the OSIVI does not auto flush by default. This is fine - my views only need to read, but from the documentation I thought that the code marked by @Transactional would continue to flush itself. Is my assumption wrong? Should I need to use FLUSH_AUTO?
Interceptor and transaction manager:
Without the AUTO FLUSH everything appeared to work without error except that nothing ever persisted.Code:<tx:annotation-driven /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <mvc:interceptors> <bean id="openSessionInView" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> <property name="flushModeName" value="FLUSH_AUTO"/> </bean> </mvc:interceptors>


Reply With Quote
