Author: stliu
Date: 2010-01-06 13:08:29 -0500 (Wed, 06 Jan 2010)
New Revision: 18424
Modified:
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java
Log:
JBPAPP-2082 ANN-841 - Bidirectional indexed collection mapped incorrectly for
IndexedCollectionTest
Modified:
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
===================================================================
---
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06
17:52:44 UTC (rev 18423)
+++
annotations/branches/v3_4_0_GA_CP/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java 2010-01-06
18:08:29 UTC (rev 18424)
@@ -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;
@@ -407,6 +408,15 @@
//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
@@ -427,7 +437,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 );
Modified:
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java
===================================================================
---
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java 2010-01-06
17:52:44 UTC (rev 18423)
+++
annotations/branches/v3_4_0_GA_CP/src/test/java/org/hibernate/test/annotations/indexcoll/AddressBook.java 2010-01-06
18:08:29 UTC (rev 18424)
@@ -42,7 +42,6 @@
@MapKey
@OneToMany(mappedBy = "book", cascade = {CascadeType.MERGE,
CascadeType.PERSIST, CascadeType.REMOVE})
- @JoinTable(name="AddRegEntry")
public Map<AddressEntryPk, AddressEntry> getEntries() {
return entries;
}
@@ -63,7 +62,6 @@
@MapKey(name = "directory")
@OneToMany(mappedBy = "book")
- @JoinTable(name="Dir_Entry")
public Map<AlphabeticalDirectory, AddressEntry> getDirectoryEntries() {
return directoryEntries;
}
Show replies by thread