diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java index edc1d878b0..6db3a28689 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java @@ -105,6 +105,7 @@ import org.hibernate.mapping.RootClass; import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.SingleTableSubclass; import org.hibernate.mapping.Subclass; +import org.hibernate.mapping.SyntheticProperty; import org.hibernate.mapping.Table; import org.hibernate.mapping.TableOwner; import org.hibernate.mapping.UnionSubclass; @@ -550,7 +551,7 @@ public class EntityBinder { propertyAccessor, isIdClass ); - final Property mapperProperty = new Property(); + final Property mapperProperty = new SyntheticProperty(); mapperProperty.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY ); mapperProperty.setUpdateable( false ); mapperProperty.setInsertable( false ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/idClass/IdClassSyntheticAttributesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/idClass/IdClassSyntheticAttributesTest.java new file mode 100644 index 0000000000..5c6b6c82a9 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/idClass/IdClassSyntheticAttributesTest.java @@ -0,0 +1,38 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.orm.test.id.idClass; + +import org.hibernate.mapping.PersistentClass; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.DomainModelScope; +import org.hibernate.testing.orm.junit.Jira; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +@DomainModel( + annotatedClasses = MyEntity.class +) +@SessionFactory +public class IdClassSyntheticAttributesTest { + + @Jira("https://hibernate.atlassian.net/browse/HHH-18841") + @Test + public void test(DomainModelScope scope) { + final PersistentClass entityBinding = scope.getDomainModel().getEntityBinding(MyEntity.class.getName()); + assertThat(entityBinding.getProperties()).hasSize(2) + .anySatisfy(p -> { + assertThat(p.isSynthetic()).isTrue(); + assertThat(p.getName()).isEqualTo("_identifierMapper"); + }) + .anySatisfy(p -> { + assertThat(p.isSynthetic()).isFalse(); + assertThat(p.getName()).isEqualTo("notes"); + }); + } +}