• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String-Hibernate read-only mode (FlushMode.NEVER)

 
Nina Anderson
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm trying to do a save and I'm getting the following error:

org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read-only mode (FlushMode.NEVER) - turn your Session into FlushMode.AUTO or remove 'readOnly' marker from transaction definition
at org.springframework.orm.hibernate3.HibernateTemplate.checkWriteOperationAllowed(HibernateTemplate.java:1098)
at org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:616)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:614)
at com.PBCoreApp.dataaccess.impl.BusinessStatisticsDAOImpl.save(BusinessStatisticsDAOImpl.java:37)

I have no idea what I'm doing wrong and how to fix it. I would appreciate any insight you can provide.

Here's my code:

//////////WEB.xml /////////////////

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>*.do</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>


/////////////////applicationContext.xml////////////////////////

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>

<bean id="businessBSTarget" class="com.PBCoreApp.business.impl.BusinessBSImpl">
<property name="businessDao"><ref local="businessDao" /></property>
<bean id="businessBS" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target">
<ref local="businessBSTarget" />
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="store*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>


////////////...Dao.java///////////////
this.getHibernateTemplate().save(businessStatisticsCbo);
this.getHibernateTemplate().flush();
this.getHibernateTemplate().clear();


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic