diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/StandardPojoEntityRepresentationStrategy.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/StandardPojoEntityRepresentationStrategy.java index edc4ce0bab..5545af6a0b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/StandardPojoEntityRepresentationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/StandardPojoEntityRepresentationStrategy.java @@ -109,13 +109,18 @@ public class StandardPojoEntityRepresentationStrategy implements EntityRepresent final KeyValue bootDescriptorIdentifier = bootDescriptor.getIdentifier(); if ( bootDescriptorIdentifier instanceof Component ) { - final Component component = (Component) bootDescriptorIdentifier; if ( bootDescriptor.getIdentifierMapper() != null ) { mapsIdRepresentationStrategy = new StandardPojoEmbeddableRepresentationStrategy( bootDescriptor.getIdentifierMapper(), creationContext ); } + else if ( bootDescriptorIdentifier != null ) { + mapsIdRepresentationStrategy = new StandardPojoEmbeddableRepresentationStrategy( + (Component) bootDescriptorIdentifier, + creationContext + ); + } else { mapsIdRepresentationStrategy = null; } 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 9e7a4169a1..a0edcb3906 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 @@ -171,17 +171,11 @@ public class MappingModelCreationHelper { propertyAccess ); Component bootComponentDescriptor = bootEntityDescriptor.getIdentifierMapper(); - final List idAttributeMappings; - final Iterator bootIdSubPropertyItr; if ( bootComponentDescriptor == null ) { - idAttributeMappings = new ArrayList<>( bootIdClassComponent.getPropertySpan() ); - bootIdSubPropertyItr = bootIdClassComponent.getPropertyIterator(); - - } - else { - idAttributeMappings = new ArrayList<>( bootComponentDescriptor.getPropertySpan() ); - bootIdSubPropertyItr = bootComponentDescriptor.getPropertyIterator(); + bootComponentDescriptor = bootIdClassComponent; } + final List idAttributeMappings = new ArrayList<>( bootComponentDescriptor.getPropertySpan() ); + final Iterator bootIdSubPropertyItr = bootComponentDescriptor.getPropertyIterator(); int columnsConsumedSoFar = 0;