HHH-18662 Add test for issue

This commit is contained in:
Andrea Boriero 2024-09-23 14:13:34 +02:00 committed by Steve Ebersole
parent c3d7e5f0b5
commit 1327f002cd
2 changed files with 6 additions and 4 deletions

View File

@ -18,6 +18,7 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Transient;
import static org.assertj.core.api.Assertions.assertThat;
@ -44,13 +45,13 @@ public class CompletePartialTests {
final ClassDetailsRegistry classDetailsRegistry = sourceModelBuildingContext.getClassDetailsRegistry();
final ClassDetails classDetails = classDetailsRegistry.getClassDetails( Thing.class.getName() );
// NOTE : `#createBuildingContext` applies `XmlProcessor`, so `@Transient` handling is applied...
// NOTE : `#createBuildingContext` applies `XmlProcessor`
assertThat( classDetails.getFields() ).hasSize( 3 );
classDetails.forEachField( (i, fieldDetails) -> {
assertThat( fieldDetails.isPersistable() ).isTrue();
final boolean expectTransient = fieldDetails.getName().equals( "somethingElse" );
assertThat( fieldDetails.hasDirectAnnotationUsage( Transient.class ) ).isEqualTo( expectTransient );
assertThat( fieldDetails.hasDirectAnnotationUsage( Transient.class ) ).isFalse();
} );
}
@ -60,6 +61,6 @@ public class CompletePartialTests {
public void testBootModel(DomainModelScope domainModelScope) {
final PersistentClass entityBinding = domainModelScope.getEntityBinding( Thing.class );
assertThat( entityBinding.getIdentifierProperty().getName() ).isEqualTo( "id" );
assertThat( entityBinding.getProperties().stream().map( Property::getName ) ).containsOnly( "name" );
assertThat( entityBinding.getProperties().stream().map( Property::getName ) ).contains( "name" ).contains( "somethingElse" );
}
}

View File

@ -12,6 +12,7 @@
<attributes>
<id name="name"/>
<id name="number"/>
<transient name="addresses"/>
</attributes>
</entity>
</entity-mappings>