hibernate/hibernate-orm · error · ModelsException
Duplicate callback method
Error message
Duplicate callback method %s '@%s' in listener class '%s'
What it means
While registering callback methods into the per-type callback map, a second method was found for a callback type that already has one in the same listener class. Indicates duplicate callback declarations (e.g. the same method reachable via both XML and annotation, or two methods for the same event); keep only one.
Solutions
- 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.
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/adb8a6cb0906aa9c.
Report an issue: GitHub.
Appendix: 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)