I'm trying to save an entity
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();
}
This methods are called from spring transactional context
@Transactional(noRollbackFor=Exception.class, propagation=Propagation.REQUIRES_NEW)
public void run() {
.
.
initRequest(data);
.
.
if (data.areRequestsNeeded()){
List<Request> requests = getRequests();
}
}
Transaction begun and is committed without any problems, but the problem is that the created lock is not still released even after Hibernate session is closed and it causes problems when I want to select data from that table
Error performing load command : org.hibernate.exception.LockAcquisitionException: lock could not be obtained within the time requested
I'm using Spring 4.0.1., Hibernate 4, Derby 10.10.1.1.
Does the Hibernate session closing release locks? How is it working? Is it a problem of spring transactional context?