hibernate/hibernate-orm · error · ModelsException

Callback method ' ' '@ ' in

Error message

Callback method '%s' %s '@%s' in '%s'%s

What it means

Generic signature check used for both XML- and annotation-declared callbacks: the method does not conform to the required void-return, single-argument shape for its consumer style (entity-internal callbacks take no args; listener callbacks take the entity). The 'source' fragment tells whether the declaration came from XML or annotation; fix the named method's signature.

Solutions

  1. Ensure the named callback method exists on the listener class with the required signature (void return, correct single parameter, accessible).

Example fix

Ensure the named callback method exists on the listener class with the required signature (void return, correct single parameter, accessible).
Defensive patterns

Strategy: validation

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

Appendix: source

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

				listenerClassDetails,
				callbackAnnotation,
				callbackType,
				methodDetails,
				callbackMethods,
				"annotated"
		);
	}

	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";
		};

View on GitHub (pinned to fad1729dce)