diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java index fa0d5a5792..a8c0657484 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/HibernateMappingProcessor.java @@ -264,9 +264,25 @@ public class HibernateMappingProcessor { private void processEntityElementImport(EntityElement entityElement) { final String qualifiedName = bindingContext().determineEntityName( entityElement ); - metadata.addImport( entityElement.getEntityName() == null - ? entityElement.getName() - : entityElement.getEntityName(), qualifiedName ); + final String importName = entityElement.getEntityName() == null + ? entityElement.getName() + : entityElement.getEntityName(); + metadata.addImport( importName, qualifiedName ); + + if ( JaxbClassElement.class.isInstance( entityElement ) ) { + processEntityElementsImport( ( (JaxbClassElement) entityElement ).getSubclass() ); + processEntityElementsImport( ( (JaxbClassElement) entityElement ).getJoinedSubclass() ); + processEntityElementsImport( ( (JaxbClassElement) entityElement ).getUnionSubclass() ); + } + else if ( JaxbSubclassElement.class.isInstance( entityElement ) ) { + processEntityElementsImport( ( (JaxbSubclassElement) entityElement ).getSubclass() ); + } + else if ( JaxbJoinedSubclassElement.class.isInstance( entityElement ) ) { + processEntityElementsImport( ( (JaxbJoinedSubclassElement) entityElement ).getJoinedSubclass() ); + } + else if ( JaxbUnionSubclassElement.class.isInstance( entityElement ) ) { + processEntityElementsImport( ( (JaxbUnionSubclassElement) entityElement ).getUnionSubclass() ); + } } private void processResultSetMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java b/hibernate-core/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java index eae8b0d882..0cafa29391 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/discriminator/DiscriminatorTest.java @@ -30,7 +30,6 @@ import org.junit.Test; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.criterion.Property; import org.hibernate.criterion.Restrictions; @@ -53,12 +52,6 @@ public class DiscriminatorTest extends BaseCoreFunctionalTestCase { return new String[] { "discriminator/Person.hbm.xml" }; } - @Override - protected void configure(Configuration configuration) { - super.configure( configuration ); - configuration.setProperty( USE_NEW_METADATA_MAPPINGS, "true" ); - } - @Test public void testDiscriminatorSubclass() { Session s = openSession();