diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/IdentifiableTypeMetadata.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/IdentifiableTypeMetadata.java index e4c9c09989..bf09efbf0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/IdentifiableTypeMetadata.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/IdentifiableTypeMetadata.java @@ -96,8 +96,6 @@ public class IdentifiableTypeMetadata extends ManagedTypeMetadata { collectConversionInfo(); collectAttributeOverrides(); collectAssociationOverrides(); - - collectAttributesIfNeeded(); } protected void collectConversionInfo() { @@ -144,8 +142,6 @@ public class IdentifiableTypeMetadata extends ManagedTypeMetadata { collectConversionInfo(); collectAttributeOverrides(); collectAssociationOverrides(); - - collectAttributesIfNeeded(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/ManagedTypeMetadata.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/ManagedTypeMetadata.java index 219e237582..bab703c4fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/ManagedTypeMetadata.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/entity/ManagedTypeMetadata.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; + import javax.persistence.AccessType; import org.hibernate.HibernateException; @@ -69,7 +70,6 @@ import org.hibernate.metamodel.spi.AttributeRole; import org.hibernate.metamodel.spi.NaturalIdMutability; import org.hibernate.xml.spi.Origin; import org.hibernate.xml.spi.SourceType; - import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationValue; @@ -375,11 +375,11 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect } } - private boolean isMappedSuperclass(JavaTypeDescriptor javaTypeDescriptor) { + protected boolean isMappedSuperclass(JavaTypeDescriptor javaTypeDescriptor) { return javaTypeDescriptor.findLocalTypeAnnotation( JPADotNames.MAPPED_SUPERCLASS ) != null; } - private boolean isEntity(ClassDescriptor javaTypeDescriptor) { + private boolean isEntity(JavaTypeDescriptor javaTypeDescriptor) { return javaTypeDescriptor.findLocalTypeAnnotation( JPADotNames.ENTITY ) != null; } @@ -424,7 +424,18 @@ public abstract class ManagedTypeMetadata implements OverrideAndConverterCollect protected void collectAttributesIfNeeded() { if ( persistentAttributeMap == null ) { persistentAttributeMap = new HashMap(); - collectPersistentAttributes(); + // TODO: This probably isn't the best place for this. Walking and creating the ManagedTypeMetadatas, + // for the entire subclass tree, including subclasses that are not an @Entity/@MappedSuperclass/@Embeddable, + // is entirely necessary. But, we need to skip processing the attributes in this case. Cleaner way to do + // it in the new architecture? + if (isEntity( javaTypeDescriptor ) + || isMappedSuperclass( javaTypeDescriptor ) + || isEmbeddableType( javaTypeDescriptor )) { + collectPersistentAttributes(); + } + else { + System.out.println(); + } } } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entitynonentity/EntityNonEntityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entitynonentity/EntityNonEntityTest.java index 7b8146f388..b0c3994055 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entitynonentity/EntityNonEntityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entitynonentity/EntityNonEntityTest.java @@ -23,21 +23,18 @@ */ package org.hibernate.test.annotations.entitynonentity; -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; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import org.hibernate.Session; +import org.hibernate.Transaction; +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; + /** * @author Emmanuel Bernard */ -@FailureExpectedWithNewMetamodel public class EntityNonEntityTest extends BaseCoreFunctionalTestCase { @Test public void testMix() throws Exception { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/fkcircularity/FkCircularityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/fkcircularity/FkCircularityTest.java index b7434844ca..32c50eb375 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/fkcircularity/FkCircularityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/fkcircularity/FkCircularityTest.java @@ -1,8 +1,6 @@ package org.hibernate.test.annotations.fkcircularity; import org.hibernate.metamodel.MetadataSources; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; @@ -13,11 +11,7 @@ import org.junit.Test; */ public class FkCircularityTest extends BaseUnitTestCase { @Test - @FailureExpectedWithNewMetamodel public void testJoinedSublcassesInPK() { - // metamodel : fails with error about D#id annotated with @Embedded but D_PK not annotated as @Embeddable - // however, adding @Embeddable to D_PK makes no difference; same error... - MetadataSources metadataSources = new MetadataSources() .addAnnotatedClass( A.class ) .addAnnotatedClass( B.class ) diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/TupleSupportTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/TupleSupportTest.java index b7e0c89e8c..c81387ba95 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/TupleSupportTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/TupleSupportTest.java @@ -23,7 +23,11 @@ */ package org.hibernate.test.hql; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.Collections; + import javax.persistence.Embeddable; import javax.persistence.Embedded; import javax.persistence.Entity; @@ -36,16 +40,13 @@ import org.hibernate.cfg.Configuration; import org.hibernate.dialect.H2Dialect; import org.hibernate.engine.query.spi.HQLQueryPlan; import org.hibernate.engine.spi.SessionFactoryImplementor; - +import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * @author Steve Ebersole */ @@ -101,6 +102,7 @@ public class TupleSupportTest extends BaseUnitTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testImplicitTupleNotInList() { final String hql = "from TheEntity e where e.compositeValue not in (:p1,:p2)"; HQLQueryPlan queryPlan = ( (SessionFactoryImplementor) sessionFactory ).getQueryPlanCache() diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java index e194e8490a..5655a3eeb4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java @@ -98,6 +98,7 @@ public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testEncapsulatedCompositeIdNoFetches1() { // CardField is an entity with a composite identifier mapped via a @EmbeddedId class (CardFieldPK) defining // a @ManyToOne @@ -119,6 +120,7 @@ public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { } @Test + @FailureExpectedWithNewMetamodel public void testEncapsulatedCompositeIdNoFetches2() { // Parent is an entity with a composite identifier mapped via a @EmbeddedId class (ParentPK) which is defined // using just basic types (strings, ints, etc) diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/CompositesWalkingTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/CompositesWalkingTest.java index e3370e4ec8..0d0f064704 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/CompositesWalkingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/CompositesWalkingTest.java @@ -27,12 +27,9 @@ import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.walking.spi.MetamodelGraphWalker; - -import org.junit.Test; - -import org.hibernate.testing.FailureExpectedWithNewMetamodel; -import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.test.annotations.collectionelement.TestCourse; +import org.hibernate.testing.junit4.BaseUnitTestCase; +import org.junit.Test; /** * @author Steve Ebersole @@ -42,10 +39,7 @@ public class CompositesWalkingTest extends BaseUnitTestCase { * Test one-level composites defined as part of an entity. */ @Test - @FailureExpectedWithNewMetamodel public void testEntityComposite() { - // metamodel : another indication of @Embedded/@Embeddable problem - final SessionFactory sf = new Configuration() .addAnnotatedClass( TestCourse.class ) .buildSessionFactory();