Announcement Announcement Module
Collapse
No announcement yet.
Transaction does not insert if readonly methods are optimize Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transaction does not insert if readonly methods are optimize

    Hi All,

    I'm not sure if i'm getting this right. But somehow the following configuration does not work if i optimize read-only methods for readOnly transactions. No inserts/updates are performed anymore if i call the service method say saveUser(modifiedUserobject).

    I use JNDI bound DS (resin), Hibernate Local Session Factory, yeah, pretty standard:

    Code:
    	<bean id="sys&#58;/db/hibernate/interceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    		<property name="sessionFactory" ref="sys&#58;/db/sessionfactory"/>
    	</bean>
    
     	<bean id="sys&#58;/db/transaction/manager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sys&#58;/db/sessionfactory"/>
    	</bean>
    
    	<bean id="sys&#58;/db/transaction/interceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        	<property name="transactionManager" ref="sys&#58;/db/transaction/manager"/>
    		<property name="transactionAttributes">
    		    <props>
    			    <prop key="*">PROPAGATION_REQUIRED</prop>
    			    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    		    </props>
    		</property>
    	</bean>
    
    
    	<bean id="ume&#58;/service/ume" class="org.springframework.aop.framework.ProxyFactoryBean">
    
        	<property name="proxyInterfaces" value="com.thyrell.cdbuddy.ume.service.IUserService"/>
    
    		<!-- The advised target wired as inner bean definition -->
    		<property name="target">
    			<bean class="com.thyrell.cdbuddy.ume.service.UserService">
    				<property name="userDao" ref="ume&#58;/dao/user"/>
    				<property name="roleDao" ref="ume&#58;/dao/role"/>
    				<property name="groupDao" ref="ume&#58;/dao/group"/>
    			</bean>
    		</property>
    
        	<property name="interceptorNames">
         		<list>
          			<value>sys&#58;/db/transaction/interceptor</value>
    				<value>sys&#58;/db/hibernate/interceptor</value>
         		</list>
        	</property>
    	</bean>
    I left out the dao definitions, since it's straight forward (injected session factory).

    OpenSessionInViewInterceptor is applied in the servlet context (urlMapping).

    Now, if i change the transaction-interceptor to:

    <prop key="*">PROPAGATION_REQUIRED</prop>

    just removing the optimization for the get* methods in the business object. Everything seems to work fine. Btw: there are no exceptions error messages and the like, hibernate just seems to ignore the modified object.

    I tried switchting the order the interceptors are applied to the service object. I searched the forum and any resource i could find, not cure.

    I really don't get it, though i'm not an AOP guru. maybe you guys see the error in a flick.

    -andi


    ah, hibernate 3rc1, spring 1.2rc1. switched to the RCs today, but does not work with hib2/spring1.1.x either

    [/code]

  • #2
    <prop key="*">PROPAGATION_REQUIRED</prop>
    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
    Try changing the order; maybe it has something to do with the matching algorithm... or maybe not.

    Comment


    • #3
      I tried that before - same behaviour.

      Is it correct how i wire up the stuff? I mean using interceptors to apply hibernate and the TA to the business layer? a while back this was the only chance to get it working with OpenSessionInView interceptor.

      I'll try to wire it up as described here:
      http://blog.exis.com/colin/archives/...ons-spring-11/.

      Other ideas or hints?

      -andi

      Comment

      Working...
      X