HHH-17177 Convert the JDBC type code for an id attribute from XML into an annotation

This commit is contained in:
marko-bekhta 2023-09-06 16:27:12 +02:00 committed by Christian Beikov
parent 8155b6bcda
commit 7048a72c61
3 changed files with 10 additions and 2 deletions

View File

@ -1768,6 +1768,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
annotationList.add( AnnotationFactory.create( id ) );
getAccessType( annotationList, element.getAccess() );
getType( annotationList, element.getType() );
getJdbcTypeCode( annotationList, element.getJdbcTypeCode() );
getUuidGenerator( annotationList, element.getUuidGenerator() );
}
}

View File

@ -35,9 +35,14 @@ public class HibernateOrmSpecificAttributesMappingTest {
@Test
public void verifyMapping(DomainModelScope scope) {
scope.withHierarchy( HibernateOrmSpecificAttributesMappingTest.MyEntity.class, (entityDescriptor) -> {
Generator generator = entityDescriptor.getIdentifierProperty().createGenerator( null );
Property identifierProperty = entityDescriptor.getIdentifierProperty();
Generator generator = identifierProperty.createGenerator( null );
assertThat( generator )
.isInstanceOf( UuidGenerator.class );
assertThat( identifierProperty.getValue() )
.isInstanceOf( BasicValue.class );
assertThat( ( (BasicValue) identifierProperty.getValue() ).getExplicitJdbcTypeCode() )
.isEqualTo( SqlTypes.CHAR );
Property name = entityDescriptor.getProperty( "name" );
assertThat( name.getValue() )

View File

@ -10,9 +10,11 @@
<package>org.hibernate.orm.test.boot.jaxb.mapping</package>
<entity class="HibernateOrmSpecificAttributesMappingTest$MyEntity">
<attributes>
<id name="id">
<!-- 1 == CHAR -->
<id name="id" jdbc-type-code="1">
<uuid-generator style="time"/>
</id>
<!-- 2005 == CLOB -->
<basic name="name" jdbc-type-code="2005"/>
<basic name="tags">
<type value="org.hibernate.orm.test.boot.jaxb.mapping.HibernateOrmSpecificAttributesMappingTest$DelimitedStringsJavaType"/>