zoukankan      html  css  js  c++  java
  • 异常:getHibernateFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getHibernateFlushMode is not valid without active transaction getHibernateFlu

    场景:

    在使用spring整合hibernate调用的HibernateTemplate时报错
    解决:

    在spring配置文件中添加事务的配置

        <bean id="hibernateTransactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
            <!-- 注入sessionFactory,配置sessionFactory -->
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
        <tx:advice id="txAdvice" transaction-manager="hibernateTransactionManager">
               <tx:attributes>
                <tx:method name="get*" read-only="true" />
                <tx:method name="*" />
            </tx:attributes>
        </tx:advice>
        <aop:config>
               <aop:pointcut id="personServiceOperation" expression="execution(* user.service.UserServiceImpl.*(..))" />
            <aop:advisor advice-ref="txAdvice" pointcut-ref="personServiceOperation" />
        </aop:config>
  • 相关阅读:
    Serverless 动态博客开发趟“坑”记
    tsv与csv文件
    zypper
    source、sh、./三种执行方式对脚本变量的影响
    linux nm
    ldconfig
    cpio
    License简介
    rpm之spec文件
    使用rpmbuild制作rpm包
  • 原文地址:https://www.cnblogs.com/hujingnb/p/10246177.html
Copyright © 2011-2022 走看看