{"record":{"id":"737318a41242e730","repo":"hibernate/hibernate-orm","slug":"you-can-only-annotate-one-callback-method-per-call-737318","errorCode":null,"errorMessage":"You can only annotate one callback method per callback type and parameter type in callback class: %s","messagePattern":"You can only annotate one callback method per callback type and parameter type in callback class: (.+?)","errorType":"exception","errorClass":"ModelsException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/models/spi/PersistenceUnitLifecycleEventHandler.java","lineNumber":186,"sourceCode":"\t\t\t&& isPersistenceUnitLifecycleTarget( methodDetails.getArgumentTypes().get( 0 ) );\n\t}\n\n\tprivate static boolean isPersistenceUnitLifecycleTarget(@Nonnull ClassDetails argumentType) {\n\t\tfinal Class<?> javaClass = argumentType.toJavaClass();\n\t\treturn javaClass == EntityManagerFactory.class\n\t\t\t|| javaClass == EntityManager.class\n\t\t\t|| javaClass == EntityAgent.class;\n\t}\n\n\tprivate static void checkDuplicate(\n\t\t\t@Nonnull ClassDetails listenerClassDetails,\n\t\t\t@Nonnull MethodDetails methodDetails,\n\t\t\t@Nonnull PersistenceUnitCallbackType callbackType,\n\t\t\t@Nonnull List<CallbackMethod> callbackMethods) {\n\t\tfor ( var callbackMethod : callbackMethods ) {\n\t\t\tif ( callbackMethod.callbackType == callbackType\n\t\t\t\t\t&& hasSameParameterType( callbackMethod.methodDetails, methodDetails ) ) {\n\t\t\t\tthrow new ModelsException( \"You can only annotate one callback method per callback type and parameter type\"\n\t\t\t\t\t\t+ \" in callback class: \" + listenerClassDetails.getClassName() );\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate static boolean hasSameParameterType(@Nonnull MethodDetails first, @Nonnull MethodDetails second) {\n\t\treturn first.getArgumentTypes().get( 0 ).toJavaClass()\n\t\t\t\t.equals( second.getArgumentTypes().get( 0 ).toJavaClass() );\n\t}\n\n\tpublic record CallbackMethod(\n\t\t\tPersistenceUnitCallbackType callbackType,\n\t\t\tMethodDetails methodDetails) {\n\t}\n}\n","sourceCodeStart":168,"sourceCodeEnd":202,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/models/spi/PersistenceUnitLifecycleEventHandler.java#L168-L202","documentation":"Error \"You can only annotate one callback method per callback type and parameter type in callback class: %s\" thrown in hibernate/hibernate-orm.","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":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}