{"record":{"id":"983528923010a754","repo":"hibernate/hibernate-orm","slug":"association-qualify-entityclassname-path-tar","errorCode":null,"errorMessage":"Association '<qualify(entityClassName, path)>' targets the type '<targetEntityName>' [which does not belong to the same persistence unit|which is not an '@Entity' type]","messagePattern":"Association '<qualify\\(entityClassName, path\\)>' targets the type '<targetEntityName>' \\[which does not belong to the same persistence unit\\|which is not an '@Entity' type\\]","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneFkSecondPass.java","lineNumber":113,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\n\t@Override\n\tpublic void doSecondPass(java.util.Map<String, PersistentClass> persistentClasses) throws MappingException {\n\t\tif ( value instanceof ManyToOne manyToOne ) {\n\t\t\t//TODO: move this validation logic to a separate ManyToOneSecondPass\n\t\t\t//      for consistency with how this is handled for OneToOnes\n\t\t\tfinal String targetEntityName = manyToOne.getReferencedEntityName();\n\t\t\tfinal var targetEntity = persistentClasses.get( targetEntityName );\n\t\t\tif ( targetEntity == null ) {\n\t\t\t\tfinal String problem = annotatedEntity\n\t\t\t\t\t\t? \" which does not belong to the same persistence unit\"\n\t\t\t\t\t\t: \" which is not an '@Entity' type\";\n\t\t\t\tthrow new AnnotationException( \"Association '\" + qualify( entityClassName, path )\n\t\t\t\t\t\t+ \"' targets the type '\" + targetEntityName + \"'\" + problem );\n\t\t\t}\n\t\t\tmanyToOne.setPropertyName( path );\n\t\t\tfinal String propertyRef = columns.getReferencedProperty();\n\t\t\tif ( propertyRef != null ) {\n\t\t\t\thandlePropertyRef(\n\t\t\t\t\t\ttargetEntity,\n\t\t\t\t\t\tmanyToOne,\n\t\t\t\t\t\tpath,\n\t\t\t\t\t\tpropertyRef,\n\t\t\t\t\t\tbuildingContext\n\t\t\t\t);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tcreateSyntheticPropertyReference(\n\t\t\t\t\t\tcolumns,\n\t\t\t\t\t\ttargetEntity,\n\t\t\t\t\t\tpersistentClass,","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneFkSecondPass.java#L95-L131","documentation":"Error \"Association '<qualify(entityClassName, path)>' targets the type '<targetEntityName>' [which does not belong to the same persistence unit|which is not an '@Entity' type]\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An entity mapping annotation or bootstrap configuration violates a Hibernate mapping rule.","commonSituations":"Annotation mapping mistakes: inverse-side @Id associations, @Column on @OneToOne, unmapped association targets, mismatched @EnumeratedValue/@Temporal usage, duplicate sequence generators.","solutions":["Annotate the target class with @Entity (or add it to orm.xml) and make sure it is included in the same persistence unit / scanned packages.","If the target is intentionally external, replace the association with a basic id attribute instead of an entity reference."],"exampleFix":"Annotate the target class with @Entity (or add it to orm.xml) and make sure it is included in the same persistence unit / scanned packages.","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"}