|
This is test case which reproduce this
@Test
public void insertEmployee(){
SessionFactoryImpl sessionFactory = (SessionFactoryImpl) factory.getCurrentSession().getSessionFactory();
EventListenerRegistry registry = sessionFactory.getServiceRegistry().getService(EventListenerRegistry.class);
PostInsertEventListener postinsertListener = new PostInsertEventListener() {
@Override
public void onPostInsert(PostInsertEvent postInsertEvent) {
Audit audit = new Audit();
audit.setId(1L);
audit.setLog("Logged event");
hibernateSession.persist(audit);
}
@Override
public boolean requiresPostCommitHanding(EntityPersister entityPersister) {
return false;
}
};
registry.prependListeners(EventType.POST_INSERT, postinsertListener);
Person person = new Person();
person.setId(1L);
person.setName("Foo Bar");
hibernateSession.save(person);
hibernateSession.flush();
}
I have run this with this configuration:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:mem:testdb;shutdown=false</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"/>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.connection.autocommit">true</property>
<property name="hibernate.hbm2ddl.auto">create-drop</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.current_session_context_class">org.hibernate.context.internal.ThreadLocalSessionContext</property>
<mapping class="cz.dmostek.test.domain.Person"/>
<mapping class="cz.dmostek.test.domain.Audit"/>
</session-factory>
</hibernate-configuration>
And with hibernate core version 4.3.0.Final. The problem is at ActionQueue.java#L347 Because in listener we add item(s) to the executable list which is being iterated. Please consider reopening the issue.
|