Use BAG for unowned OneToMany and throw an error if @OrderColumn is found on unowned ManyToMany
This commit is contained in:
parent
8183901cfe
commit
b6b500200b
|
@ -2377,6 +2377,17 @@ public final class AnnotationBinder {
|
|||
);
|
||||
}
|
||||
|
||||
if ( property.isAnnotationPresent( OrderColumn.class )
|
||||
&& manyToManyAnn != null && !manyToManyAnn.mappedBy().isEmpty() ) {
|
||||
throw new AnnotationException(
|
||||
"Explicit @OrderColumn on inverse side of @ManyToMany is illegal: "
|
||||
+ BinderHelper.getPath(
|
||||
propertyHolder,
|
||||
inferredData
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
final IndexColumn indexColumn = IndexColumn.fromAnnotations(
|
||||
property.getAnnotation( OrderColumn.class ),
|
||||
property.getAnnotation( org.hibernate.annotations.IndexColumn.class ),
|
||||
|
|
|
@ -565,6 +565,11 @@ public abstract class CollectionBinder {
|
|||
// We don't support @OrderColumn on the non-owning side of a many-to-many association.
|
||||
return CollectionClassification.BAG;
|
||||
}
|
||||
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
|
||||
if ( oneToMany != null && ! StringHelper.isEmpty( oneToMany.mappedBy() ) ) {
|
||||
// Unowned to-many mappings are always considered BAG by default
|
||||
return CollectionClassification.BAG;
|
||||
}
|
||||
// otherwise, return the implicit classification for List attributes
|
||||
return buildingContext.getBuildingOptions().getMappingDefaults().getImplicitListClassification();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue