Skip to content

Commit

Permalink
HHH-17377 - Migrate to JPA 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Nov 17, 2023
1 parent a21ac74 commit 6bf399b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public Object resolveEntity(String publicID, String systemID, String baseURI, St

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
Expand All @@ -57,6 +57,9 @@ else if ( MappingXsdSupport.jpa30.getNamespaceUri().matches( namespace ) ) {
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() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,9 @@ private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElem
}

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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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 );
} );
}
Expand All @@ -46,7 +52,11 @@ private void verify(String resourceName, ClassLoaderService cls, ServiceRegistry
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 );
}
Expand Down

0 comments on commit 6bf399b

Please sign in to comment.