Permalink
Browse files

HHH-7981 - Load (now) locally defined orm.xsd while processing orm.xm…

…l files
  • Loading branch information...
1 parent fbdca39 commit 467daa22b077b5f0fbfc37a706371fd8839cecf2 @sebersole sebersole committed Mar 21, 2013
@@ -84,7 +84,7 @@ task jaxb {
// input schemas
cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd')
hbmXsd = file( 'src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd' )
- ormXsd = file( 'src/main/resources/org/hibernate/ejb/orm_2_0.xsd' )
+ ormXsd = file( 'src/main/resources/org/hibernate/jpa/orm_2_0.xsd' )
// input bindings
cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' )
@@ -56,37 +56,57 @@ public boolean isResolved() {
@Override
public InputSource resolveEntity(String publicId, String systemId) {
LOG.tracev( "Resolving XML entity {0} : {1}", publicId, systemId );
- InputSource is = super.resolveEntity( publicId, systemId );
- if ( is == null ) {
- if ( systemId != null ) {
- if ( systemId.endsWith( "orm_1_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_1_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if (source != null) return source;
+ if ( systemId != null ) {
+ if ( systemId.endsWith( "orm_2_1.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "orm_2_1.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
+ if ( source != null ) {
+ return source;
}
- else if ( systemId.endsWith( "orm_2_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_2_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if (source != null) return source;
+ }
+ else if ( systemId.endsWith( "orm_2_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "orm_2_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
+ if ( source != null ) {
+ return source;
}
- else if ( systemId.endsWith( "persistence_1_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_1_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if (source != null) return source;
+ }
+ else if ( systemId.endsWith( "orm_1_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "orm_1_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
+ if ( source != null ) {
+ return source;
}
- else if ( systemId.endsWith( "persistence_2_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_2_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if (source != null) return source;
+ }
+ else if ( systemId.endsWith( "persistence_2_1.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "persistence_2_1.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
+ if ( source != null ) {
+ return source;
+ }
+ }
+ else if ( systemId.endsWith( "persistence_2_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "persistence_2_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
+ if ( source != null ) {
+ return source;
+ }
+ }
+ else if ( systemId.endsWith( "persistence_1_0.xsd" ) ) {
+ InputStream dtdStream = getStreamFromClasspath( "persistence_1_0.xsd" );
+ final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
+ if ( source != null ) {
+ return source;
}
}
}
- else {
+
+ // because the old code did this too (in terms of setting resolved)
+ InputSource source = super.resolveEntity( publicId, systemId );
+ if ( source != null ) {
resolved = true;
- return is;
}
- //use the default behavior
- return null;
+ return source;
}
private InputSource buildInputSource(String publicId, String systemId, InputStream dtdStream, boolean resolved) {
@@ -103,8 +123,8 @@ private InputSource buildInputSource(String publicId, String systemId, InputStre
}
private InputStream getStreamFromClasspath(String fileName) {
- LOG.trace( "Recognized JPA ORM namespace; attempting to resolve on classpath under org/hibernate/ejb" );
- String path = "org/hibernate/ejb/" + fileName;
+ LOG.trace( "Recognized JPA ORM namespace; attempting to resolve on classpath under org/hibernate/jpa" );
+ String path = "org/hibernate/jpa/" + fileName;
InputStream dtdStream = resolveInHibernateNamespace( path );
return dtdStream;
}
@@ -58,33 +58,24 @@ public ErrorLogger(String file) {
this.file = file;
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void error(SAXParseException error) {
if ( this.errors == null ) {
errors = new ArrayList<SAXParseException>();
}
errors.add( error );
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void fatalError(SAXParseException error) {
error( error );
}
- /**
- * {@inheritDoc}
- */
+ @Override
public void warning(SAXParseException warn) {
LOG.parsingXmlWarning( warn.getLineNumber(), warn.getMessage() );
}
- /**
- * @return returns a list of encountered xml parsing errors, or the empty list if there was no error
- */
public List<SAXParseException> getErrors() {
return errors;
}
Oops, something went wrong.

0 comments on commit 467daa2

Please sign in to comment.