zoukankan      html  css  js  c++  java
  • No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration

    No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
    org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

    调用到这里的时候:

    @Transactional
    public SimpleContract getSimpleContractById(String simpleContractId){
    return hibernateDao.get(SimpleContract.class, simpleContractId);
    }

    出现的异常的,经查看

    上层调用方法:

    public void printed(SimpleContract simpleContract){
    SimpleContract SsimpleContract1 = getSimpleContractById(simpleContract.getContractId());
    SsimpleContract1.setStatus(ContractConstants.printed);
    saveContract(SsimpleContract1);
    }

    需要在上层调用方法的地方添加事务

    @Transactional
    public void printed(SimpleContract simpleContract){
    SimpleContract SsimpleContract1 = getSimpleContractById(simpleContract.getContractId());
    SsimpleContract1.setStatus(ContractConstants.printed);
    saveContract(SsimpleContract1);
    }

  • 相关阅读:
    微信验证代码
    微信内置浏览器的JS API
    伪类和伪元素
    asp.net core mvc 脚手架搭建过程介绍
    C#无锁内存队列
    关于微软OWIN的一篇好文章
    安装了Win10预览版10074,不能设置开发模式的bug解决
    关于Quartz的一些经历
    MEF接口应用初探
    简单的接口框架
  • 原文地址:https://www.cnblogs.com/tiramisuyj/p/6076695.html
Copyright © 2011-2022 走看看