[hibernate-commits] Hibernate SVN: r14062 - core/trunk/core/src/main/java/org/hibernate/cfg.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Oct 5 08:55:35 EDT 2007


Author: d.plentz
Date: 2007-10-05 08:55:35 -0400 (Fri, 05 Oct 2007)
New Revision: 14062

Modified:
   core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java
Log:
[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

Modified: core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java	2007-10-05 12:49:52 UTC (rev 14061)
+++ core/trunk/core/src/main/java/org/hibernate/cfg/HbmBinder.java	2007-10-05 12:55:35 UTC (rev 14062)
@@ -632,10 +632,7 @@
 
 		// 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 @@
 			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 @@
 			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 @@
 			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() );




More information about the hibernate-commits mailing list