{"record":{"id":"adb8a6cb0906aa9c","repo":"hibernate/hibernate-orm","slug":"duplicate-callback-method-s-s-in-listener-cla","errorCode":null,"errorMessage":"Duplicate callback method %s '@%s' in listener class '%s'","messagePattern":"Duplicate callback method (.+?) '@(.+?)' in listener class '(.+?)'","errorType":"exception","errorClass":"ModelsException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/models/spi/LifecycleEventHandler.java","lineNumber":693,"sourceCode":"\t}\n\n\tprivate static void setCallbackMethod(\n\t\t\tJpaEventListenerStyle consumerType,\n\t\t\tClassDetails listenerClassDetails,\n\t\t\tClass<? extends Annotation> callbackAnnotation,\n\t\t\tCallbackType callbackType,\n\t\t\tMethodDetails methodDetails,\n\t\t\tMap<CallbackType, MethodDetails> callbackMethods,\n\t\t\tString source) {\n\t\tif ( !matchesSignature( consumerType, methodDetails ) ) {\n\t\t\tthrow new ModelsException( \"Callback method '\"\n\t\t\t\t\t+ methodDetails.getName() + \"' \" + source + \" '@\"\n\t\t\t\t\t+ callbackAnnotation.getSimpleName() + \"' in '\"\n\t\t\t\t\t+ listenerClassDetails.getClassName() + \"'\"\n\t\t\t\t\t+ signatureRequirement( consumerType ) );\n\t\t}\n\t\tif ( callbackMethods.containsKey( callbackType ) ) {\n\t\t\tthrow new ModelsException( \"Duplicate callback method \" + source + \" '@\"\n\t\t\t\t\t+ callbackAnnotation.getSimpleName() + \"' in listener class '\"\n\t\t\t\t\t+ listenerClassDetails.getClassName() + \"'\" );\n\t\t}\n\t\tcallbackMethods.put( callbackType, methodDetails );\n\t}\n\n\tprivate static String signatureRequirement(JpaEventListenerStyle consumerType) {\n\t\treturn switch ( consumerType ) {\n\t\t\tcase CALLBACK -> \" must return void and take no arguments\";\n\t\t\tcase LISTENER -> \" must return void and take one argument\";\n\t\t};\n\t}\n\n\tpublic static boolean matchesSignature(JpaEventListenerStyle callbackType, MethodDetails methodDetails) {\n\t\treturn switch ( callbackType ) {\n\t\t\tcase CALLBACK ->\n\t\t\t\t// should have no arguments, and technically (spec) have a void return\n\t\t\t\t\tmethodDetails.getArgumentTypes().isEmpty()","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/models/spi/LifecycleEventHandler.java#L675-L711","documentation":"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.","triggerScenarios":"A JPA entity-listener or lifecycle callback violates the callback contract.","commonSituations":"Listener classes with missing lifecycle annotations, wrong method signatures, or multiple methods for the same event type.","solutions":["Keep a single callback method per lifecycle event type (and parameter type) in the listener/callback class; merge the logic of the duplicates."],"exampleFix":"Keep a single callback method per lifecycle event type (and parameter type) in the listener/callback class; merge the logic of the duplicates.","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}