PreLoadEvent listeners might receive events with null state, which never happened in hibernate 5
{code:java}@Entity @Table(name = "ENTITY_A") public class EntityA {
@Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "ID") Integer id; }{code}
{code:java}public class MyPreLoadEventListener implements PreLoadEventListener {
@Override public void onPreLoad(PreLoadEvent event) { assertThat(event.getState()).isNotNull(); } }{code}
{code:java} @Test public void foobarTest() throws Exception { // BaseCoreFunctionalTestCase automatically creates the SessionFactory and // provides the Session. try (Session s = openSession()) { Transaction tx = s.beginTransaction(); EntityA entityA1 = new EntityA();
s.persist(entityA1); tx.commit(); }
try (Session s = openSession()) { Transaction tx = s.beginTransaction(); String hql = "select e from org.hibernate.bugs.EntityA e"; Query<EntityA> query = s.createQuery(hql, EntityA.class); List<EntityA> actual = query.list(); assertThat(actual).hasSize(1); tx.rollback(); } }{code}
Test case to be attached and also available here [https://github.com/ratoaq2/HHH-16350|https://github.com/ratoaq2/HHH-16350|smart-link] |
|