Revert "HHH-7940 - Add validation check for indexed fake bidirectional mappings."
This reverts commit af9882baae
.
This commit is contained in:
parent
e3bd5a56d2
commit
0efd03419e
|
@ -152,19 +152,6 @@ public final class CollectionMetadataGenerator {
|
|||
final boolean owningManyToOneWithJoinTableBidirectional = (value instanceof ManyToOne) && (propertyAuditingData.getRelationMappedBy() != null);
|
||||
final boolean fakeOneToManyBidirectional = (value instanceof OneToMany) && (propertyAuditingData.getAuditMappedBy() != null);
|
||||
|
||||
// HHH-7940
|
||||
// When a @OneToMany(mappedBy="..") is mapped with a @ManyToOne without a join table and the @OneToMany
|
||||
// uses an @IndexColumn/@OrderColumn annotation, a mapping exception is thrown to indicate how to
|
||||
// properly map this relation as it needs to be considered a 'fakeOneToManyBidirectional' mapping.
|
||||
if ( propertyAuditingData.isIndexed() ) {
|
||||
if ( oneToManyAttachedType && inverseOneToMany && !fakeOneToManyBidirectional && !owningManyToOneWithJoinTableBidirectional ) {
|
||||
throw new MappingException(
|
||||
"Mapping failure for [" + referencingEntityConfiguration.getEntityClassName() + "#" + propertyName + "]: " +
|
||||
"An indexed @OneToMany should be mapped by also using @JoinColumn and @AuditMappedBy."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( oneToManyAttachedType && (inverseOneToMany || fakeOneToManyBidirectional || owningManyToOneWithJoinTableBidirectional) ) {
|
||||
// A one-to-many relation mapped using @ManyToOne and @OneToMany(mappedBy="...")
|
||||
addOneToManyAttached( fakeOneToManyBidirectional );
|
||||
|
|
|
@ -17,11 +17,9 @@ import java.util.Set;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.MapKey;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderColumn;
|
||||
import javax.persistence.Version;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.annotations.IndexColumn;
|
||||
import org.hibernate.annotations.common.reflection.ClassLoadingException;
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.annotations.common.reflection.XClass;
|
||||
|
@ -522,7 +520,6 @@ public class AuditedPropertiesReader {
|
|||
addPropertyMapKey( property, propertyData );
|
||||
setPropertyAuditMappedBy( property, propertyData );
|
||||
setPropertyRelationMappedBy( property, propertyData );
|
||||
setPropertyIndexed( property, propertyData );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -593,12 +590,6 @@ public class AuditedPropertiesReader {
|
|||
}
|
||||
}
|
||||
|
||||
private void setPropertyIndexed(XProperty property, PropertyAuditingData propertyData) {
|
||||
if ( property.isAnnotationPresent( OrderColumn.class ) || property.isAnnotationPresent( IndexColumn.class ) ) {
|
||||
propertyData.setIndexed( true );
|
||||
}
|
||||
}
|
||||
|
||||
private void addPropertyMapKey(XProperty property, PropertyAuditingData propertyData) {
|
||||
final MapKey mapKey = property.getAnnotation( MapKey.class );
|
||||
if ( mapKey != null ) {
|
||||
|
|
|
@ -35,7 +35,6 @@ public class PropertyAuditingData {
|
|||
private boolean forceInsertable;
|
||||
private boolean usingModifiedFlag;
|
||||
private String modifiedFlagName;
|
||||
private boolean indexed;
|
||||
|
||||
public PropertyAuditingData() {
|
||||
}
|
||||
|
@ -162,14 +161,6 @@ public class PropertyAuditingData {
|
|||
this.modifiedFlagName = modifiedFlagName;
|
||||
}
|
||||
|
||||
public boolean isIndexed() {
|
||||
return indexed;
|
||||
}
|
||||
|
||||
public void setIndexed(boolean indexed) {
|
||||
this.indexed = indexed;
|
||||
}
|
||||
|
||||
public void addAuditingOverride(AuditOverride annotation) {
|
||||
if ( annotation != null ) {
|
||||
final String overrideName = annotation.name();
|
||||
|
|
Loading…
Reference in New Issue