Skip to content

Commit a26e505

Browse files
marko-bekhtabeikov
authored andcommitted
HHH-18841 Create _identifierMapper as a synthetic attribute
1 parent 1ffde48 commit a26e505

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
import org.hibernate.mapping.SimpleValue;
106106
import org.hibernate.mapping.SingleTableSubclass;
107107
import org.hibernate.mapping.Subclass;
108+
import org.hibernate.mapping.SyntheticProperty;
108109
import org.hibernate.mapping.Table;
109110
import org.hibernate.mapping.TableOwner;
110111
import org.hibernate.mapping.UnionSubclass;
@@ -550,7 +551,7 @@ private Component createMapperProperty(
550551
propertyAccessor,
551552
isIdClass
552553
);
553-
final Property mapperProperty = new Property();
554+
final Property mapperProperty = new SyntheticProperty();
554555
mapperProperty.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
555556
mapperProperty.setUpdateable( false );
556557
mapperProperty.setInsertable( false );
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Hibernate, Relational Persistence for Idiomatic Java
3+
*
4+
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
5+
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
6+
*/
7+
package org.hibernate.orm.test.id.idClass;
8+
9+
import org.hibernate.mapping.PersistentClass;
10+
import org.hibernate.testing.orm.junit.DomainModel;
11+
import org.hibernate.testing.orm.junit.DomainModelScope;
12+
import org.hibernate.testing.orm.junit.Jira;
13+
import org.hibernate.testing.orm.junit.SessionFactory;
14+
import org.junit.jupiter.api.Test;
15+
16+
import static org.assertj.core.api.Assertions.assertThat;
17+
18+
@DomainModel(
19+
annotatedClasses = MyEntity.class
20+
)
21+
@SessionFactory
22+
public class IdClassSyntheticAttributesTest {
23+
24+
@Jira("https://hibernate.atlassian.net/browse/HHH-18841")
25+
@Test
26+
public void test(DomainModelScope scope) {
27+
final PersistentClass entityBinding = scope.getDomainModel().getEntityBinding(MyEntity.class.getName());
28+
assertThat(entityBinding.getProperties()).hasSize(2)
29+
.anySatisfy(p -> {
30+
assertThat(p.isSynthetic()).isTrue();
31+
assertThat(p.getName()).isEqualTo("_identifierMapper");
32+
})
33+
.anySatisfy(p -> {
34+
assertThat(p.isSynthetic()).isFalse();
35+
assertThat(p.getName()).isEqualTo("notes");
36+
});
37+
}
38+
}

0 commit comments

Comments
 (0)