HHH-17377 - Migrate to JPA 3.2

https://hibernate.atlassian.net/browse/HHH-17377

Latest JPA 3.2 XSD changes - 9cca8e2432/api/src/main/resources/jakarta/persistence/orm_3_2.xsd
This commit is contained in:
Steve Ebersole 2023-11-06 20:44:18 -06:00
parent 181e32b5d7
commit e12d633c89
3 changed files with 17 additions and 5 deletions

View File

@ -40,8 +40,8 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
if ( namespace != null ) {
log.debugf( "Interpreting namespace : %s", namespace );
if ( MappingXsdSupport._310.getNamespaceUri().matches( namespace ) ) {
return openUrlStream( MappingXsdSupport._310 );
if ( MappingXsdSupport.latestDescriptor().getNamespaceUri().matches( namespace ) ) {
return openUrlStream( MappingXsdSupport.latestDescriptor() );
}
if ( MappingXsdSupport.jpa10.getNamespaceUri().matches( namespace ) ) {
// JPA 1.0 and 2.0 share the same namespace URI
@ -57,6 +57,9 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver {
else if ( MappingXsdSupport.jpa31.getNamespaceUri().matches( namespace ) ) {
return openUrlStream( MappingXsdSupport.jpa31 );
}
else if ( MappingXsdSupport.jpa32.getNamespaceUri().matches( namespace ) ) {
return openUrlStream( MappingXsdSupport.jpa32 );
}
else if ( ConfigXsdSupport.getJPA10().getNamespaceUri().matches( namespace ) ) {
// JPA 1.0 and 2.0 share the same namespace URI
return openUrlStream( ConfigXsdSupport.getJPA10() );

View File

@ -93,10 +93,9 @@ public class MappingEventReader extends EventReaderDelegate {
}
private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
// Here we look to see if this attribute is the JPA version attribute, and if so do 3 things:
// Here we look to see if this attribute is the JPA version attribute, and if so do the following:
// 1) validate its version attribute is valid per our "latest XSD"
// 2) update its version attribute to the latest version if not already
// 3) if the latest XSD version is not in the XML list of valid versions, add it to avoid validation errors
//
// NOTE : atm this is a very simple check using just the attribute's local name
// rather than checking its qualified name. It is possibly (though unlikely)

View File

@ -36,6 +36,12 @@ public class BasicMappingJaxbTests {
public void simpleUnifiedJaxbTest(ServiceRegistryScope scope) {
scope.withService( ClassLoaderService.class, (cls) -> {
verify( "xml/jaxb/mapping/basic/unified.xml", cls, scope );
} );
}
@Test
public void ormBaselineTest(ServiceRegistryScope scope) {
scope.withService( ClassLoaderService.class, (cls) -> {
verify( "xml/jaxb/mapping/basic/orm.xml", cls, scope );
} );
}
@ -47,7 +53,11 @@ public class BasicMappingJaxbTests {
final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
try {
final JAXBContext jaxbCtx = JAXBContext.newInstance( JaxbEntityMappingsImpl.class );
final JaxbEntityMappingsImpl entityMappings = JaxbHelper.VALIDATING.jaxb( reader, MappingXsdSupport._310.getSchema(), jaxbCtx );
final JaxbEntityMappingsImpl entityMappings = JaxbHelper.VALIDATING.jaxb(
reader,
MappingXsdSupport.latestDescriptor().getSchema(),
jaxbCtx
);
assertThat( entityMappings ).isNotNull();
assertThat( entityMappings.getEntities() ).hasSize( 1 );
}