Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushM...

只读模式下(FlushMode.NEVER/MANUAL)写操作不被允许:把你的Session改成FlushMode.COMMIT/AUTO或者清除事务定义中的readOnly标记。

在applicationContext.xml中添加如下配置:

 1     <!--事务管理器-->
 2     <bean id="txManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
 3         <property name="sessionFactory" ref="sessionFactory"></property>
 4     </bean>
 5 
 6     <aop:config>
 7         <!-- execution(public * *.*.*..*.*(..)) 为自己项目中操作数据库中的方法 -->
 8         <aop:pointcut id="pointcut" expression="execution(* com.gyf.bos.dao..*.*(..))" />
 9         <aop:advisor pointcut-ref="pointcut" advice-ref="txAdvice" />
10     </aop:config>
11 
12     <!-- 配置事务增强 -->
13     <tx:advice id="txAdvice" transaction-manager="txManager">
14         <tx:attributes>
15             <!-- 配置需要进行事务管理的方法,和事务传播行为 -->
16             <tx:method name="save*" propagation="REQUIRED" read-only="false"/>
17             <tx:method name="update*" propagation="REQUIRED" read-only="false"/>
18             <tx:method name="delete*" propagation="REQUIRED" read-only="false"/>
19         </tx:attributes>
20     </tx:advice>

说明:execution(* com.gyf.bos.dao..*.*(..))

    该步骤还没有添加service,后期会整合,在这里仅提供配置参考

转载于:https://www.cnblogs.com/116970u/p/11106839.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值