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

posted @ 2016-11-18 10:36  tiramisuyj  阅读(545)  评论(0编辑  收藏  举报