# Post-commit-\* listeners not firing

**URL:** <https://discourse.hibernate.org/t/post-commit-listeners-not-firing/11874>\
**Category:** Hibernate ORM\
**Created:** [October 15, 2025, 3:16pm UTC](https://discourse.hibernate.org/t/post-commit-listeners-not-firing/11874 "2025-10-15T15:16:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![s.goetz](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@s.goetz](https://discourse.hibernate.org/u/s.goetz)\
**Post date:** [October 15, 2025, 3:16pm UTC](https://discourse.hibernate.org/t/post-commit-listeners-not-firing/11874/1 "2025-10-15T15:16:35Z")

</div>

Hello everyone,

We have been successfully using Hibernate for several years. We use a technology stack consisting of Spring and Hibernate, along with Envers auditing. Some key aspects of the solution are based on EntityListeners. We register them as follows:

```java
@PostConstruct
void selfRegister()
{
	if (sessionFactory instanceof final SessionFactoryImplementor sessionFactoryImplementor)
	{
		// As you might expect, an EventListenerRegistry is the place with which event listeners are registered
		// It is a service so we look it up using the service registry
		final EventEngine eventEngine = sessionFactoryImplementor.getEventEngine();
		final EventListenerRegistry eventListenerRegistry = eventEngine.getListenerRegistry();
			
		// add the listener to the end of the listener chain
		eventListenerRegistry.appendListeners(EventType.PERSIST, EntityListener.this);
		eventListenerRegistry.appendListeners(EventType.MERGE, EntityListener.this);
		eventListenerRegistry.appendListeners(EventType.PRE_INSERT, EntityListener.this);
        eventListenerRegistry.appendListeners(EventType.POST_COMMIT_INSERT, EntityListener.this);
		eventListenerRegistry.appendListeners(EventType.POST_COMMIT_UPDATE, EntityListener.this);
		eventListenerRegistry.appendListeners(EventType.POST_COMMIT_DELETE, EntityListener.this);
		eventListenerRegistry.appendListeners(EventType.POST_COLLECTION_UPDATE, EntityListener.this);
	}
	else
	{
		throw new IllegalStateException("Unable to register entity listeners!");
	}
}

```

We are currently working on updating hibernate from version 5 to version 7 (7.1.0.final in detail) using JDK 21. We have not changed the above code section. However, we can see that the listeners for the following events are no longer being called.

- POST\_COMMIT\_INSERT
- POST\_COMMIT\_UPDATE
- POST\_COMMIT\_DELETE
- POST\_COLLECTION\_UPDATE

We’re using annotation-driven transactions with Spring’s @Transactional annotations. Do we need to change any configuration or explicitly enable these events?

```xml
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
		<qualifier value="txmUserDB"></qualifier>
		<property name="sessionFactory" ref="sessionFactoryUser" />
	</bean>

	<!-- enable the configuration of transactional behavior based on annotations -->
  	<tx:annotation-driven transaction-manager="transactionManager"/>

```

Kind regards

Sebastian

---

<div class="post-metadata">

**Author:** ![s.goetz](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@s.goetz](https://discourse.hibernate.org/u/s.goetz)\
**Post date:** [October 16, 2025, 6:00am UTC](https://discourse.hibernate.org/t/post-commit-listeners-not-firing/11874/2 "2025-10-16T06:00:50Z")

</div>

Okay, I guess I didn’t dig deep enough. Anyway, I can answer my own question here in case anyone has a similar problem.

In Hibernate 5, the method

```java
org.hibernate.event.spi.PostActionEventListener.requiresPostCommitHandling(EntityPersister)

```

internally called the abstract (deprecated) method

```java
org.hibernate.event.spi.PostActionEventListener.requiresPostCommitHanding(EntityPersister)

```

This was implemented by my listener implementations and always returned `true`.  
With Hibernate 7, this method was finally removed, and the return value of the former method was changed to `false`. This resulted in all POST-COMMIT listeners no longer being called in my software.  
The solution is to implement the method `org.hibernate.event.spi.PostActionEventListener.requiresPostCommitHandling(EntityPersister)` (this uses a default implementation at the interface level) and return `true` here like this:

```java
eventListenerRegistry.appendListeners(EventType.POST_COMMIT_INSERT, new PostCommitInsertEventListener()
{
	@Override
	public void onPostInsert(final PostInsertEvent pEvent)
	{
		// TODO: implement your magic here
	}

	@Override
	public void onPostInsertCommitFailed(final PostInsertEvent pEvent)
	{
		// TODO: handle failed commit if necessary
	}
	
	@Override
	public boolean requiresPostCommitHandling(final EntityPersister pPersister)
	{
        // indicate the action queue that this listener requires post-commit handling
		return true;
	}
});

```

Have a nice day!
