From 048fd365306798ac935cb9d3ade178b027797902 Mon Sep 17 00:00:00 2001 From: Strong Liu Date: Tue, 28 May 2013 15:02:56 -0700 Subject: [PATCH] HHH-7919 : xsd mapping was not generacted correctly, which was forcing the order of elements which doesn't required by the old dtd --- .../hibernate/InvalidMappingException.java | 2 +- .../hibernate/metamodel/MetadataSources.java | 2 +- .../spi/source/InvalidMappingException.java | 9 +++ .../org/hibernate/hibernate-mapping-4.0.xsd | 56 ++++++++++--------- .../DiscrimSubclassFilterTest.java | 2 - .../JoinedSubclassFilterTest.java | 2 - .../UnionSubclassFilterTest.java | 2 - .../subclassfilter/union-subclass.hbm.xml | 2 +- 8 files changed, 42 insertions(+), 35 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java index 0b91c5ca94..9b475f4497 100644 --- a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java +++ b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java @@ -124,7 +124,7 @@ public class InvalidMappingException extends MappingException { * @param origin The origin of the invalid mapping document * @param cause The underlying cause */ - public InvalidMappingException(String customMessage, Origin origin, Exception cause) { + public InvalidMappingException(String customMessage, Origin origin, Throwable cause) { this( customMessage, origin.getType().name(), origin.getName(), cause ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java index 79b2757c04..4f5a9020c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/MetadataSources.java @@ -255,7 +255,7 @@ public class MetadataSources { return jaxbRoot; } catch ( Exception e ) { - throw new InvalidMappingException( origin ); + throw new InvalidMappingException( origin, e ); } finally { if ( close ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/InvalidMappingException.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/InvalidMappingException.java index 1c510fc52d..8d7314d202 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/InvalidMappingException.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/InvalidMappingException.java @@ -43,6 +43,15 @@ public class InvalidMappingException extends org.hibernate.InvalidMappingExcepti this.origin = origin; } + public InvalidMappingException(Origin origin, Throwable e) { + super( + String.format( "Could not parse mapping document: %s (%s)", origin.getName(), origin.getType() ), + origin, + e + ); + this.origin = origin; + } + public Origin getOrigin() { return origin; } diff --git a/hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd b/hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd index 737ed29a98..ba00f02f74 100644 --- a/hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd +++ b/hibernate-core/src/main/resources/org/hibernate/hibernate-mapping-4.0.xsd @@ -23,37 +23,40 @@ arbitrary number of queries, and import declarations of arbitrary classes. --> - - + + + + + + + - + - + - + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + + - - + + diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java index 2815a79426..459d7806be 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -40,7 +39,6 @@ import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase { @Override public final String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java index 4d1502b30a..9bb706840a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java @@ -33,7 +33,6 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.dialect.CUBRIDDialect; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -42,7 +41,6 @@ import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel @SkipForDialect( value = CUBRIDDialect.class, comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java index 0a224d890d..44eb7feb7f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/UnionSubclassFilterTest.java @@ -32,7 +32,6 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -40,7 +39,6 @@ import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ -@FailureExpectedWithNewMetamodel public class UnionSubclassFilterTest extends BaseCoreFunctionalTestCase { @Override public final String[] getMappings() { diff --git a/hibernate-core/src/test/resources/org/hibernate/test/subclassfilter/union-subclass.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/test/subclassfilter/union-subclass.hbm.xml index 9b19b550fd..79e1ab7448 100644 --- a/hibernate-core/src/test/resources/org/hibernate/test/subclassfilter/union-subclass.hbm.xml +++ b/hibernate-core/src/test/resources/org/hibernate/test/subclassfilter/union-subclass.hbm.xml @@ -8,7 +8,7 @@ - +