From c861e465a7d57be68cd8a62215e9487507d53dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 28 Jan 2022 16:00:58 +0100 Subject: [PATCH] HHH-15057 Fix exception on persisting bidirectional, list many-to-many association --- .../java/org/hibernate/cfg/annotations/CollectionBinder.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java index d814282c11..12a8a78b31 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java @@ -557,6 +557,11 @@ public abstract class CollectionBinder { || property.isAnnotationPresent( OrderBy.class ) ) { return CollectionClassification.BAG; } + ManyToMany manyToMany = property.getAnnotation( ManyToMany.class ); + if ( manyToMany != null && ! StringHelper.isEmpty( manyToMany.mappedBy() ) ) { + // We don't support @OrderColumn on the non-owning side of a many-to-many association. + return CollectionClassification.BAG; + } // otherwise, return the implicit classification for List attributes return buildingContext.getBuildingOptions().getMappingDefaults().getImplicitListClassification(); }