• 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,后期会整合,在这里仅提供配置参考

  • 相关阅读:
    javascript金额千分位的实现
    html中仿GroupBox效果与路径问题
    javascript获取表格的高度
    分布式系统的架构思路
    sharepoint2010 Reporting Services 集成注意
    Ext.MessageBox.updateProgress
    认识RFID
    Extjs 下拉ComboBox分页,图片,多行显示
    MVCFckEditor一些小问题
    MVCFckEditor
  • 原文地址:https://www.cnblogs.com/116970u/p/11106839.html
Copyright © 2020-2023  润新知