Hello,
Some background… migrating jakarta appication from
- hibernate 5->hibernate 6
- deltaspike → jakarta data
Application uses Envers to audit entities.
Jpamodelgen generates Repositories implementation with StatelessSession
@PostConstruct
private void openSession() {
session = sessionFactory.unwrap(SessionFactory.class).openStatelessSession();
}
and the problem is when entity is saved StatelessSessionImple fires event:
PreInsertEvent event = new PreInsertEvent(entity, id, state, persister, (EventSource)null);
and then:
public class EnversPostInsertEventListenerImpl extends BaseEnversEventListener implements PostInsertEventListener {
public EnversPostInsertEventListenerImpl(EnversService enversService) {
super( enversService );
}
@Override
public void onPostInsert(PostInsertEvent event) {
final String entityName = event.getPersister().getEntityName();
if ( getEnversService().getEntitiesConfigurations().isVersioned( entityName ) ) {
checkIfTransactionInProgress( event.getSession() );
all fails with error:
Caused by: java.lang.NullPointerException: Cannot invoke "org.hibernate.engine.spi.SessionImplementor.isTransactionInProgress()" because "session" is null
at org.hibernate@6.6.3.Final//org.hibernate.envers.event.spi.BaseEnversEventListener.checkIfTransactionInProgress(BaseEnversEventListener.java:134)
at org.hibernate@6.6.3.Final//org.hibernate.envers.event.spi.EnversPostInsertEventListenerImpl.onPostInsert(EnversPostInsertEventListenerImpl.java:34)
at org.hibernate@6.6.3.Final//org.hibernate.internal.StatelessSessionImpl.firePostInsert(StatelessSessionImpl.java:380)
at org.hibernate@6.6.3.Final//org.hibernate.internal.StatelessSessionImpl.insert(StatelessSessionImpl.java:160)
at org.hibernate@6.6.3.Final//org.hibernate.internal.StatelessSessionImpl.insert(StatelessSessionImpl.java:118)
Is there some solution for this ?