HHH-16849 Fix partition key inside multi-column foreign key

This commit is contained in:
Marco Belladelli 2023-07-04 15:05:57 +02:00 committed by Steve Ebersole
parent b9e8d71dc8
commit 78cc85aa05
1 changed files with 4 additions and 1 deletions

View File

@ -207,6 +207,7 @@ public class MappingModelCreationHelper {
final FetchTiming fetchTiming; final FetchTiming fetchTiming;
final FetchStyle fetchStyle; final FetchStyle fetchStyle;
final boolean partitioned;
if ( declaringType instanceof EmbeddableMappingType ) { if ( declaringType instanceof EmbeddableMappingType ) {
if ( bootProperty.isLazy() ) { if ( bootProperty.isLazy() ) {
MAPPING_MODEL_CREATION_MESSAGE_LOGGER.debugf( MAPPING_MODEL_CREATION_MESSAGE_LOGGER.debugf(
@ -217,10 +218,12 @@ public class MappingModelCreationHelper {
} }
fetchTiming = FetchTiming.IMMEDIATE; fetchTiming = FetchTiming.IMMEDIATE;
fetchStyle = FetchStyle.JOIN; fetchStyle = FetchStyle.JOIN;
partitioned = value.isPartitionKey() && !( (EmbeddableMappingType) declaringType ).getEmbeddedValueMapping().isVirtual();
} }
else { else {
fetchTiming = bootProperty.isLazy() ? FetchTiming.DELAYED : FetchTiming.IMMEDIATE; fetchTiming = bootProperty.isLazy() ? FetchTiming.DELAYED : FetchTiming.IMMEDIATE;
fetchStyle = bootProperty.isLazy() ? FetchStyle.SELECT : FetchStyle.JOIN; fetchStyle = bootProperty.isLazy() ? FetchStyle.SELECT : FetchStyle.JOIN;
partitioned = value.isPartitionKey();
} }
return new BasicAttributeMapping( return new BasicAttributeMapping(
@ -244,7 +247,7 @@ public class MappingModelCreationHelper {
nullable, nullable,
insertable, insertable,
updateable, updateable,
value.isPartitionKey(), partitioned,
attrType, attrType,
declaringType, declaringType,
propertyAccess propertyAccess