hibernate/hibernate-orm · error · ModelsException

Duplicate callback method %s '@%s' in listener class '%s'

Error message

Duplicate callback method %s '@%s' in listener class '%s'

What it means

Error "Duplicate callback method %s '@%s' in listener class '%s'" thrown in hibernate/hibernate-orm.

Source

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

	}

	private static void setCallbackMethod(
			JpaEventListenerStyle consumerType,
			ClassDetails listenerClassDetails,
			Class<? extends Annotation> callbackAnnotation,
			CallbackType callbackType,
			MethodDetails methodDetails,
			Map<CallbackType, MethodDetails> callbackMethods,
			String source) {
		if ( !matchesSignature( consumerType, methodDetails ) ) {
			throw new ModelsException( "Callback method '"
					+ methodDetails.getName() + "' " + source + " '@"
					+ callbackAnnotation.getSimpleName() + "' in '"
					+ listenerClassDetails.getClassName() + "'"
					+ signatureRequirement( consumerType ) );
		}
		if ( callbackMethods.containsKey( callbackType ) ) {
			throw new ModelsException( "Duplicate callback method " + source + " '@"
					+ callbackAnnotation.getSimpleName() + "' in listener class '"
					+ listenerClassDetails.getClassName() + "'" );
		}
		callbackMethods.put( callbackType, methodDetails );
	}

	private static String signatureRequirement(JpaEventListenerStyle consumerType) {
		return switch ( consumerType ) {
			case CALLBACK -> " must return void and take no arguments";
			case LISTENER -> " must return void and take one argument";
		};
	}

	public static boolean matchesSignature(JpaEventListenerStyle callbackType, MethodDetails methodDetails) {
		return switch ( callbackType ) {
			case CALLBACK ->
				// should have no arguments, and technically (spec) have a void return
					methodDetails.getArgumentTypes().isEmpty()

View on GitHub (pinned to fad1729dce)

Solutions

  1. Keep a single callback method per lifecycle event type (and parameter type) in the listener/callback class; merge the logic of the duplicates.

Example fix

Keep a single callback method per lifecycle event type (and parameter type) in the listener/callback class; merge the logic of the duplicates.

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/adb8a6cb0906aa9c. Report an issue: GitHub.