From 78cc85aa0590aed7a7455c837da476b2b3d317ce Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Tue, 4 Jul 2023 15:05:57 +0200 Subject: [PATCH] HHH-16849 Fix partition key inside multi-column foreign key --- .../mapping/internal/MappingModelCreationHelper.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index cd24deb515..5c28207012 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -207,6 +207,7 @@ public class MappingModelCreationHelper { final FetchTiming fetchTiming; final FetchStyle fetchStyle; + final boolean partitioned; if ( declaringType instanceof EmbeddableMappingType ) { if ( bootProperty.isLazy() ) { MAPPING_MODEL_CREATION_MESSAGE_LOGGER.debugf( @@ -217,10 +218,12 @@ public class MappingModelCreationHelper { } fetchTiming = FetchTiming.IMMEDIATE; fetchStyle = FetchStyle.JOIN; + partitioned = value.isPartitionKey() && !( (EmbeddableMappingType) declaringType ).getEmbeddedValueMapping().isVirtual(); } else { fetchTiming = bootProperty.isLazy() ? FetchTiming.DELAYED : FetchTiming.IMMEDIATE; fetchStyle = bootProperty.isLazy() ? FetchStyle.SELECT : FetchStyle.JOIN; + partitioned = value.isPartitionKey(); } return new BasicAttributeMapping( @@ -244,7 +247,7 @@ public class MappingModelCreationHelper { nullable, insertable, updateable, - value.isPartitionKey(), + partitioned, attrType, declaringType, propertyAccess