{"record":{"id":"ada4c8844339b197","repo":"hibernate/hibernate-orm","slug":"use-of-the-same-entity-name-twice-name","errorCode":null,"errorMessage":"Use of the same entity name twice: ${name}","messagePattern":"Use of the same entity name twice: (.+?)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":1489,"sourceCode":"\t\t\tthrow new MappingException( \"@Mutability is not allowed on entity\" );\n\t\t}\n\t}\n\n\tprivate boolean isMutable() {\n\t\treturn !annotatedClass.hasAnnotationUsage( Immutable.class, modelsContext() );\n\t}\n\n\tprivate void registerImportName() {\n\t\ttry {\n\t\t\tfinal var metadataCollector = getMetadataCollector();\n\t\t\tmetadataCollector.addImport( name, persistentClass.getEntityName() );\n\t\t\tfinal String entityName = persistentClass.getEntityName();\n\t\t\tif ( !entityName.equals( name ) ) {\n\t\t\t\tmetadataCollector.addImport( entityName, entityName );\n\t\t\t}\n\t\t}\n\t\tcatch (MappingException me) {\n\t\t\tthrow new AnnotationException( \"Use of the same entity name twice: \" + name, me );\n\t\t}\n\t}\n\n\tprivate void bindRootEntity() {\n\t\tfinal var rootClass = (RootClass) persistentClass;\n\t\trootClass.setMutable( isMutable() );\n\t\tif ( isNotBlank( where ) ) {\n\t\t\trootClass.setWhere( where );\n\t\t}\n\t\tif ( cacheConcurrentStrategy != null ) {\n\t\t\trootClass.setCacheConcurrencyStrategy( cacheConcurrentStrategy );\n\t\t\trootClass.setCacheRegionName( cacheRegion );\n\t\t\trootClass.setLazyPropertiesCacheable( cacheLazyProperty );\n\t\t}\n\t\trootClass.setNaturalIdCacheRegionName( naturalIdCacheRegion );\n\t\trootClass.setNaturalIdClass( naturalIdClass );\n\t}\n","sourceCodeStart":1471,"sourceCodeEnd":1507,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L1471-L1507","documentation":"Error \"Use of the same entity name twice: ${name}\" thrown in hibernate/hibernate-orm.","triggerScenarios":"Two managed types are registered under the same entity name.","commonSituations":"Duplicate @Entity(name=...) values or two classes with the same simple name in one persistence unit.","solutions":["Rename one of the entities so each entity name is unique in the persistence unit."],"exampleFix":null,"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"}