Announcement Announcement Module
Collapse
No announcement yet.
InvalidDataAccessApiUsageException when switching to 1.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • InvalidDataAccessApiUsageException when switching to 1.1

    Hi,

    we tried to switch to 1.1 today but now we get the following exception:

    Code:
    org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO respectively remove 'readOnly' marker from transaction definition
    	org.springframework.orm.hibernate.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:901)
    	org.springframework.orm.hibernate.HibernateTemplate$13.doInHibernate(HibernateTemplate.java:319)
    	org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
    	org.springframework.orm.hibernate.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:317)
    	wilken.openshop.modules.base.dao.support.hibernate.BaseDaoSupport.saveOrUpdate(BaseDaoSupport.java:227)
    	wilken.openshop.modules.base.logic.support.BaseLogicSupport.saveOrUpdate(BaseLogicSupport.java:248)
    	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	java.lang.reflect.Method.invoke(Method.java:324)
    	org.springframework.aop.framework.AopProxyUtils.invokeJoinpointUsingReflection(AopProxyUtils.java:61)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:149)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:116)
    	org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
    	org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:138)
    	org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:152)
    	$Proxy0.saveOrUpdate(Unknown Source)
    We use declarative transaction support using
    @@org.springframework.transaction.interceptor.Defa ultTransactionAttribute() on service objects (readOnly=false).

    We also use the OpenSessionInViewInterceptor. Before 1.1 everything worked fine. Now because the FlushMode of the OpenSessionInViewInterceptor is set to NEVER I get this exception.

    Should we set the flush mode to AUTO? Will this have any negative impact on the transaction management, in other words will the flushing of the session then still be controlled by the existing Transaction?

    Could anybody please clarify this point.
    Thanks in advance.

    juergen

  • #2
    InvalidDataAccessApiUsageException when switching to 1.1

    Well nobody seems to answer

    Here is what we did.

    Added
    Code:
    <property name="flushModeName">
          <value>FLUSH_AUTO</value>
    </property>
    to the OpenSessionInViewInterceptor.

    Works.
    Thanx for nothing.
    j.

    Comment


    • #3
      I assume you're working with JtaTransactionManager: This issue shouldn't happen with HibernateTransactionManager, which sets the FlushMode of a pre-bound Session temporarily to AUTO for the execution of a non-read-only transaction.

      Actually, this shouldn't have worked quite so well with JtaTransactionManager in 1.0.2: While HibernateTemplate did accept write operations in any case, those wouldn't have been flushed at transaction completion, because the JTA session synchronization would only cause a flush if not in FlushMode NEVER. Consequently, as long as you hadn't called flush yourself, your changes would not have been persisted...

      Thus, it is indeed currently necessary to set OpenSessionInViewInterceptor/Filter to FlushMode AUTO when working with JtaTransactionManager, to properly get transactional changes flushed. While that will work, it's preferable to have the Session in FlushMode NEVER outside of a transaction: Therefore, I'm gonna look at this issue for the 1.1.1 release.

      Juergen

      Comment


      • #4
        Indeed we are working with the JtaTransactionManager. Thanks for your answer.

        juergen

        Comment

        Working...
        X