hibernate/hibernate-orm · error · ModelsException

Mapping for entity listener '%s' specified no callback metho

Error message

Mapping for entity listener '%s' specified no callback methods

What it means

Error "Mapping for entity listener '%s' specified no callback methods" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/models/spi/LifecycleEventHandler.java:289

						methodDetails,
						callbackMethods ) ) {
			mutableMethodDetails.addAnnotationUsage( annotationDescriptor.createUsage( modelsContext ) );
		}
	}

	private static boolean isImplicitMethodMappings(JaxbEntityListenerImpl jaxbMapping) {
		return jaxbMapping.getPrePersist() == null
			&& jaxbMapping.getPreUpdate() == null
			&& jaxbMapping.getPreRemove() == null
			&& jaxbMapping.getPostLoad() == null
			&& jaxbMapping.getPostPersist() == null
			&& jaxbMapping.getPostUpdate() == null
			&& jaxbMapping.getPostRemove() == null;
	}

	private static void errorIfEmpty(LifecycleEventHandler descriptor) {
		if ( !descriptor.hasCallbackMethods() ) {
			throw new ModelsException( "Mapping for entity listener '"
										+ descriptor.listenerClass.getClassName()
										+ "' specified no callback methods" );
		}
	}

	/// Create a handler from annotations based on annotated methods on the given `listenerClassDetails`.
	/// Used from XML parsing when no explicit methods are identified indicating that we should use
	/// whatever event annotations are available, and errror if none are found.
	private static LifecycleEventHandler from(JpaEventListenerStyle consumerType, ClassDetails listenerClassDetails) {
		return from( consumerType, listenerClassDetails, true );
	}

	/// Create a handler from annotations based on annotated methods on the given `listenerClassDetails`.
	public static LifecycleEventHandler from(
			JpaEventListenerStyle consumerType,
			ClassDetails listenerClassDetails,
			boolean errorIfEmpty) {
		final EnumMap<CallbackType, MethodDetails> callbackMethods = new EnumMap<>( CallbackType.class );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Annotate at least one method of the entity listener with a lifecycle annotation (@PrePersist, @PostLoad, etc.) or remove the listener registration.

Example fix

Annotate at least one method of the entity listener with a lifecycle annotation (@PrePersist, @PostLoad, etc.) or remove the listener registration.

When it happens

Trigger: A JPA entity-listener or lifecycle callback violates the callback contract.

Common situations: Listener classes with missing lifecycle annotations, wrong method signatures, or multiple methods for the same event type.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/9f55eca03508e7d7. Report an issue: GitHub.