HHH-9231 Rolled back entity insert remains in level 2 collection cache in JBoss EAP 6

Solution In Progress - Updated -

Issue

  • A OneToMany association is defined between two entity types
@Entity
public class Department {
    @OneToMany(...)
    private List<Employee> employees;
}

@Entity
public class Employee {
    @ManyToOne(...)
    private Department department;
}
  • In a transaction, create an instance referencing the "One" class without updating the association collection, flush the session, initialize the association collection then rollback
    Department dept = ... // load a department but do not initialize its employees list
    entityManager.persist(new Employee("John Smith", dept));
    entityManager.flush()
    List<Employee> worksIn = dept.getEmployees();
    tx.rollback();
  • After rollback, the association collection retains a reference to the non-existent (rolled back) entity and access to the association may result in javax.persistence.EntityNotFoundException

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP) 6
  • Hibernate 4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.