I use jHipster with Spring Data JPA and have the following method:
@Transactional(propagation=Propagation.REQUIRES_NEW)
public void doSomeWork(EntityA entityA) {
// some code
List<EntityB> entityBList = new ArrayList<EntityB>();
entityBList.add(new EntityB());
entityA.addAllEntityB(entityBList);
}
At the last line I get an org.hibernate.LazyInitializationException excption which I don't understand.
- Why is it throwing this excption although the method is run in its own transaction?
- Should it not just lazy load the list as the session is still open?