我正在尝试保存实体
protected void initRequest(T data) {
Request request = new Request();
data.setPosRequest(request);
request.setTimeStamp(new DateTime());
request.setType(REQUEST);
Session session = sessionFactory.getCurrentSession();
session.save(request);
logger.info("Newly created request: {}", request);
}
protected List<Request> getRequests(){
return (List<Request>) sessionFactory.
getCurrentFactory().
createQuery("from Requests").
list();
}
此方法从spring transactional context
调用@Transactional(noRollbackFor=Exception.class, propagation=Propagation.REQUIRES_NEW)
public void run() {
.
.
initRequest(data);
.
.
if (data.areRequestsNeeded()){
List<Request> requests = getRequests();
}
}
事务开始并且没有任何问题地提交,但问题是即使在Hibernate会话关闭后仍然没有释放创建的锁,当我想从该表中选择数据时它会导致问题
Error performing load command : org.hibernate.exception.LockAcquisitionException: lock could not be obtained within the time requested
我正在使用Spring 4.0.1。,Hibernate 4,Derby 10.10.1.1。
Hibernate会话关闭版本是否锁定?它是如何工作的?这是春季交易背景的问题吗?