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);
    }

  • 相关阅读:
    1250. Check If It Is a Good Array
    380. Insert Delete GetRandom O(1)
    378. Kth Smallest Element in a Sorted Matrix
    341. Flatten Nested List Iterator
    387. First Unique Character in a String
    454. 4Sum II
    D
    勇敢的妞妞 ( 状压 + 思维)
    P1879 [USACO06NOV]玉米田Corn Fields (状压dp入门)
    G
  • 原文地址:https://www.cnblogs.com/tiramisuyj/p/6076695.html
Copyright © 2011-2022 走看看