<!--指定事务管理器-->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!--使用代理来实现事务的切入!-->
<bean id="userDaoProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<!--代理类使用事务管理器实现事务管理-->
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<!--指定受管理的目标-->
<property name="target">
<ref local="userDao" />
</property>
<property name="proxyInterfaces">
<list>
<value>com.achievo.flower.uac.dao.UserDao</value>
</list>
</property>
<!--指定事务属性-->
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
不知道哪里出错了,增加用户的时候出现Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory" />
</property>
</bean>
<!--使用代理来实现事务的切入!-->
<bean id="userDaoProxy"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<!--代理类使用事务管理器实现事务管理-->
<property name="transactionManager">
<ref bean="transactionManager" />
</property>
<!--指定受管理的目标-->
<property name="target">
<ref local="userDao" />
</property>
<property name="proxyInterfaces">
<list>
<value>com.achievo.flower.uac.dao.UserDao</value>
</list>
</property>
<!--指定事务属性-->
<property name="transactionAttributes">
<props>
<prop key="add*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>
不知道哪里出错了,增加用户的时候出现Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' er from transaction definition.
<prop key="add*">PROPAGATION_REQUIRED,-Throwable</prop>
<prop key="find*">PROPAGATION_REQUIRED,readOnly </prop>
readOnly 只读了还能写了吗?
Throwable所有异常均回滚。