From 6188eeb68125acad8577889e3f8213aa4457633a Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 19 Apr 2023 16:12:05 +0200 Subject: [PATCH] HHH-16493 OneToManyCollectionPart doesn't disassemble properly embeddable IdClass --- .../internal/AbstractEntityCollectionPart.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityCollectionPart.java index 24b7548c43..2f7b85ca8c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityCollectionPart.java @@ -12,6 +12,7 @@ import java.util.Set; import org.hibernate.annotations.NotFoundAction; import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; +import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.StringHelper; import org.hibernate.mapping.Collection; import org.hibernate.mapping.IndexedCollection; @@ -195,6 +196,17 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa return associatedEntityTypeDescriptor.createDomainResult( navigablePath, partTableGroup, resultVariable, creationState ); } + @Override + public Object disassemble(Object value, SharedSessionContractImplementor session) { + if ( value == null ) { + return null; + } + + // should be an instance of the associated entity + return getAssociatedEntityMappingType().getIdentifierMapping().getIdentifier( value ); + } + + @Override public EntityFetch generateFetch( FetchParent fetchParent,