Skip to content

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public Object resolveEntity(String publicID, String systemID, String baseURI, St
4040

4141
if ( namespace != null ) {
4242
log.debugf( "Interpreting namespace : %s", namespace );
43-
if ( MappingXsdSupport._310.getNamespaceUri().matches( namespace ) ) {
44-
return openUrlStream( MappingXsdSupport._310 );
43+
if ( MappingXsdSupport.latestDescriptor().getNamespaceUri().matches( namespace ) ) {
44+
return openUrlStream( MappingXsdSupport.latestDescriptor() );
4545
}
4646
if ( MappingXsdSupport.jpa10.getNamespaceUri().matches( namespace ) ) {
4747
// JPA 1.0 and 2.0 share the same namespace URI
@@ -57,6 +57,9 @@ else if ( MappingXsdSupport.jpa30.getNamespaceUri().matches( namespace ) ) {
5757
else if ( MappingXsdSupport.jpa31.getNamespaceUri().matches( namespace ) ) {
5858
return openUrlStream( MappingXsdSupport.jpa31 );
5959
}
60+
else if ( MappingXsdSupport.jpa32.getNamespaceUri().matches( namespace ) ) {
61+
return openUrlStream( MappingXsdSupport.jpa32 );
62+
}
6063
else if ( ConfigXsdSupport.getJPA10().getNamespaceUri().matches( namespace ) ) {
6164
// JPA 1.0 and 2.0 share the same namespace URI
6265
return openUrlStream( ConfigXsdSupport.getJPA10() );

hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/MappingEventReader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,9 @@ private Iterator<Attribute> existingXmlAttributesIterator(StartElement startElem
9393
}
9494

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

hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/mapping/BasicMappingJaxbTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public class BasicMappingJaxbTests {
3636
public void simpleUnifiedJaxbTest(ServiceRegistryScope scope) {
3737
scope.withService( ClassLoaderService.class, (cls) -> {
3838
verify( "xml/jaxb/mapping/basic/unified.xml", cls, scope );
39+
} );
40+
}
41+
42+
@Test
43+
public void ormBaselineTest(ServiceRegistryScope scope) {
44+
scope.withService( ClassLoaderService.class, (cls) -> {
3945
verify( "xml/jaxb/mapping/basic/orm.xml", cls, scope );
4046
} );
4147
}
@@ -47,7 +53,11 @@ private void verify(String resourceName, ClassLoaderService cls, ServiceRegistry
4753
final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
4854
try {
4955
final JAXBContext jaxbCtx = JAXBContext.newInstance( JaxbEntityMappingsImpl.class );
50-
final JaxbEntityMappingsImpl entityMappings = JaxbHelper.VALIDATING.jaxb( reader, MappingXsdSupport._310.getSchema(), jaxbCtx );
56+
final JaxbEntityMappingsImpl entityMappings = JaxbHelper.VALIDATING.jaxb(
57+
reader,
58+
MappingXsdSupport.latestDescriptor().getSchema(),
59+
jaxbCtx
60+
);
5161
assertThat( entityMappings ).isNotNull();
5262
assertThat( entityMappings.getEntities() ).hasSize( 1 );
5363
}

0 commit comments

Comments
 (0)