Skip to content

Commit

Permalink
HHH-18841 Create _identifierMapper as a synthetic attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta authored and beikov committed Nov 15, 2024
1 parent 1ffde48 commit a26e505
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
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;
Expand Down Expand Up @@ -550,7 +551,7 @@ private Component createMapperProperty(
propertyAccessor,
isIdClass
);
final Property mapperProperty = new Property();
final Property mapperProperty = new SyntheticProperty();
mapperProperty.setName( NavigablePath.IDENTIFIER_MAPPER_PROPERTY );
mapperProperty.setUpdateable( false );
mapperProperty.setInsertable( false );
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
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");
});
}
}

0 comments on commit a26e505

Please sign in to comment.