From b6792bdb19ddda71279bbc4e6563b8c1b4d9dc02 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Thu, 27 Oct 2022 19:42:13 +0200 Subject: [PATCH] HHH-13054 handle referencedColumnName to entities with multiple @Id properties --- .../src/main/java/org/hibernate/cfg/BinderHelper.java | 11 ++++++++++- .../model/domain/internal/EntityTypeImpl.java | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java index c431db0a1c..8274d12d31 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java @@ -430,7 +430,16 @@ public class BinderHelper { for ( Property property : persistentClass.getProperties() ) { matchColumnsByProperty( property, columnsToProperty ); } - matchColumnsByProperty( persistentClass.getIdentifierProperty(), columnsToProperty ); + if ( persistentClass.hasIdentifierProperty() ) { + matchColumnsByProperty( persistentClass.getIdentifierProperty(), columnsToProperty ); + } + else { + // special case for entities with multiple @Id properties + Component key = persistentClass.getIdentifierMapper(); + for ( Property p : key.getProperties() ) { + matchColumnsByProperty( p, columnsToProperty ); + } + } } else { for ( Property property : ((Join) columnOwner).getProperties() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java index 6534d3f18a..9eea3516f1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/EntityTypeImpl.java @@ -52,7 +52,8 @@ public class EntityTypeImpl persistentClass.getEntityName(), javaType, superType, - persistentClass.getDeclaredIdentifierMapper() != null || ( superType != null && superType.hasIdClass() ), + persistentClass.getDeclaredIdentifierMapper() != null + || superType != null && superType.hasIdClass(), persistentClass.hasIdentifierProperty(), persistentClass.isVersioned(), jpaMetamodel