zoukankan      html  css  js  c++  java
  • Write operations are not allowed in read-only mode (FlushMode.MANUAL): Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.

    只读模式下(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,后期会整合,在这里仅提供配置参考

  • 相关阅读:
    DIV+CSS布局一行两列问题(Repeater布局)
    JavaScript为DropDownList添加新项
    Indexof的实现
    父类子类构造函数的执行顺序
    微软算法面试题(2)
    Heaven on Earth
    阿里巴巴笔试题马尔科夫(HMM)的特征
    心灵净化启示录
    职场英语:开心工作的十二条秘诀
    MySql错误代码1045的解决方案
  • 原文地址:https://www.cnblogs.com/116970u/p/11106839.html
Copyright © 2011-2022 走看看