As part of hibernate migration from 3 to 5, i am facing some issues related to the transactional entity.
I am using Spring and hibernate and in this case, i am using spring managed Transactional annotation.
Consider the case where One method with transactional calls 2 different methods with/without the transaction.
In hibernate 3 it used to work properly. But after upgrade to hibernate 5 setEMSStatus is failing as subscribedEms is null.
//Class1
@Transactional(rollbackFor = Exception.class)
public void validateAndSave(List<EmsDto> gridList) {
//Removing unnecessary code
emsEntityManager.createAndSaveSubscribedEms(EmsDto.getMessageName(), EmsDto.getDescription(), SubscribeEmsStatus.UNKNOWN.toString());
//Removing unnecessary code
emsEntityManager.setEMSStatus(entry.getKey(), SubscribeEmsStatus.VALID.toString());
}
//Class2
@Transactional
public void createAndSaveSubscribedEms(final String messageName, final String description, final String status) {
session.save(SubscribedEms.create(messageName, description, status));
}
// Note: No transactional and it was working earlier in hibernate 3
public void setEMSStatus(String emsName, String newStatus) {
SubscribedEms subscribedEms = (SubscribedEms) session.createCriteria(SubscribedEms.class).
add(Restrictions.eq(SubscribedEms_.messageName, emsName)).
uniqueResult();
subscribedEms.setStatus(newStatus);
}
I came across a similar issue
I want to know if there is any change in the way Transaction is managed.
I agree @Transactional is from spring. I have upgraded just hibernate and no changes were made to spring.
Below is the configuration xml (Spring 4.3.4, Hibernate 5.1.15 & Jboss 10).
Should i set any hibernate property or any spring-hibernate configuration ?
I have started discussion but still no help from the spring community