wood burning stoves 2.0*
The moose likes Spring and the fly likes spring Transaction mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL on Excption Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "spring Transaction mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL on Excption " Watch "spring Transaction mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL on Excption " New topic
Author

spring Transaction mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL on Excption

samuel soundra rajan
Greenhorn

Joined: Sep 25, 2009
Posts: 5
We are using Spring declarative Trsnaction in service layer with Hibernate Transaction Manager and OpenSessionInViewFilter .

<filter>
<filter-name>OSIV</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>

<bean id="integrationServiceTransactionInterceptor" class="org.springframework.transaction.interceptor .TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributeSource">
<value>
PermissionService.*=PROPAGATION_REQUIRED,timeout_$ {transaction.timeout.update}
PermissionService.find*=PROPAGATION_REQUIRED,readO nly,timeout_${transaction.timeout.readonly}
</value>
</property>
</bean>

<bean id="restartTransactionInterceptor" class="com.novacitynets.pavo.common.util.RestartTr ansactionAdviser">

Also we are using RestartTransactionAdviser intercertor to restart the transaction if deadLock or lock Exception occured.

sample code:

public Object invoke(MethodInvocation invocation) throws Throwable {
return restart(invocation, 1);
}

private Object restart(MethodInvocation invocation, int attempt)
throws Throwable {
Object rval = null;
try {
rval = invocation.proceed();
} catch (Exception e) {
Thread.sleep(timeout);
attempt++;
return restart(invocation, attempt);

}
return rval;
}


But while restarting the transaction the mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL automaically
so it is giving Exception org.springframework.dao.InvalidDataAccessApiUsageE xception: Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition on completing the transaction


Samuel.S
(Java Programmer)

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: spring Transaction mode changed from FlushMode.COMMIT/AUTO to FlushMode.NEVER/MANUAL on Excption
 
Similar Threads
Exception on Save operation with Spring annotation
Deadlock problems with Hibernate/Spring/MS-SQL
unsatisfied Dependancy exception
String-Hibernate read-only mode (FlushMode.NEVER)
Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL)