Results 1 to 4 of 4

Thread: InvalidDataAccessApiUsageException when switching to 1.1

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Ulm, Germany
    Posts
    4

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Ulm, Germany
    Posts
    4

    Default 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.

  3. #3
    Join Date
    Aug 2004
    Location
    Linz, Austria
    Posts
    391

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Location
    Ulm, Germany
    Posts
    4

    Default

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

    juergen

Similar Threads

  1. Replies: 6
    Last Post: Jun 24th, 2008, 02:33 PM
  2. Replies: 13
    Last Post: Oct 30th, 2007, 04:04 PM
  3. Replies: 8
    Last Post: Dec 12th, 2006, 05:40 AM
  4. Replies: 4
    Last Post: Aug 28th, 2006, 01:31 AM
  5. Odd PostgreSQL problem
    By crazeinc in forum Data
    Replies: 13
    Last Post: Oct 3rd, 2005, 09:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •