[hibernate-commits] Hibernate SVN: r18425 - annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Wed Jan 6 13:42:18 EST 2010


Author: stliu
Date: 2010-01-06 13:42:18 -0500 (Wed, 06 Jan 2010)
New Revision: 18425

Modified:
   annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
Log:
JBPAPP-2082 ANN-841 - Bidirectional indexed collection mapped incorrectly for IndexedCollectionTest

Modified: annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
--- annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/CollectionBinder.java	2010-01-06 18:08:29 UTC (rev 18424)
+++ annotations/branches/v3_3_1_GA_CP/src/java/org/hibernate/cfg/annotations/CollectionBinder.java	2010-01-06 18:42:18 UTC (rev 18425)
@@ -11,6 +11,7 @@
 import javax.persistence.AttributeOverrides;
 import javax.persistence.Embeddable;
 import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
 import javax.persistence.JoinTable;
 import javax.persistence.ManyToMany;
 import javax.persistence.MapKey;
@@ -405,13 +406,20 @@
 
 		//work on association
 		boolean isMappedBy = !BinderHelper.isDefault( mappedBy );
+		if (isMappedBy
+				&& (property.isAnnotationPresent( JoinColumn.class )
+					|| property.isAnnotationPresent( JoinTable.class ) ) ) {
+			String message = "Associations marked as mappedBy must not define database mappings like @JoinTable or @JoinColumn: ";
+			message += StringHelper.qualify( propertyHolder.getPath(), propertyName );
+			throw new AnnotationException( message );
+		}
 		collection.setInverse( isMappedBy );
 
 		//many to many may need some second pass informations
 		if ( !oneToMany && isMappedBy ) {
 			mappings.addMappedBy( getCollectionType().getName(), mappedBy, propertyName );
 		}
-		//TODO reducce tableBinder != null and oneToMany
+		//TODO reduce tableBinder != null and oneToMany
 		XClass collectionType = getCollectionType();
 		SecondPass sp = getSecondPass(
 				fkJoinColumns,
@@ -425,7 +433,7 @@
 		);
 		if ( collectionType.isAnnotationPresent( Embeddable.class )
 				|| property.isAnnotationPresent( CollectionOfElements.class ) ) {
-			// do it right away, otherwise @ManyToon on composite element call addSecondPass 
+			// do it right away, otherwise @ManyToOne on composite element call addSecondPass 
 			// and raise a ConcurrentModificationException
 			//sp.doSecondPass( CollectionHelper.EMPTY_MAP );
 			mappings.addSecondPass( sp, !isMappedBy );



More information about the hibernate-commits mailing list