From ec267130cdb6c424a2b32b29ed9a9178eb2660ba Mon Sep 17 00:00:00 2001 From: Diego Plentz Date: Fri, 5 Oct 2007 12:55:35 +0000 Subject: [PATCH] [HHH-2598] Mapping a collection of entities from two different classes with the same collection name results in duplicate backref property exception if collection keys are not null git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14062 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- core/src/main/java/org/hibernate/cfg/HbmBinder.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/hibernate/cfg/HbmBinder.java b/core/src/main/java/org/hibernate/cfg/HbmBinder.java index 4b288c3e2f..c794818b7b 100644 --- a/core/src/main/java/org/hibernate/cfg/HbmBinder.java +++ b/core/src/main/java/org/hibernate/cfg/HbmBinder.java @@ -632,10 +632,7 @@ public final class HbmBinder { // PERSISTER Attribute persisterNode = node.attribute( "persister" ); - if ( persisterNode == null ) { - // persister = SingleTableEntityPersister.class; - } - else { + if ( persisterNode != null ) { try { entity.setEntityPersisterClass( ReflectHelper.classForName( persisterNode .getValue() ) ); @@ -2249,7 +2246,7 @@ public final class HbmBinder { String entityName = ( (OneToMany) list.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); IndexBackref ib = new IndexBackref(); - ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" ); + ib.setName( '_' + list.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( list.getRole() ); @@ -2352,7 +2349,7 @@ public final class HbmBinder { String entityName = ( (OneToMany) map.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); IndexBackref ib = new IndexBackref(); - ib.setName( '_' + node.attributeValue( "name" ) + "IndexBackref" ); + ib.setName( '_' + map.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "IndexBackref" ); ib.setUpdateable( false ); ib.setSelectable( false ); ib.setCollectionRole( map.getRole() ); @@ -2485,7 +2482,7 @@ public final class HbmBinder { String entityName = ( (OneToMany) collection.getElement() ).getReferencedEntityName(); PersistentClass referenced = mappings.getClass( entityName ); Backref prop = new Backref(); - prop.setName( '_' + node.attributeValue( "name" ) + "Backref" ); + prop.setName( '_' + collection.getOwnerEntityName() + "." + node.attributeValue( "name" ) + "Backref" ); prop.setUpdateable( false ); prop.setSelectable( false ); prop.setCollectionRole( collection.getRole() );