HHH-4283 fix the incorrect test case and add a proper exception when the user error occurs
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18421 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
99e43e9d14
commit
658df91a5e
|
@ -35,6 +35,7 @@ import javax.persistence.AttributeOverrides;
|
|||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.MapKey;
|
||||
|
@ -464,6 +465,15 @@ public abstract class CollectionBinder {
|
|||
|
||||
//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
|
||||
|
@ -487,7 +497,7 @@ public abstract class CollectionBinder {
|
|||
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy hibernate
|
||||
|| property.isAnnotationPresent( ElementCollection.class ) //JPA 2
|
||||
) {
|
||||
// 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 );
|
||||
|
|
|
@ -42,7 +42,6 @@ public class AddressBook {
|
|||
|
||||
@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 @@ public class AddressBook {
|
|||
|
||||
@MapKey(name = "directory")
|
||||
@OneToMany(mappedBy = "book")
|
||||
@JoinTable(name="Dir_Entry")
|
||||
public Map<AlphabeticalDirectory, AddressEntry> getDirectoryEntries() {
|
||||
return directoryEntries;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue