From d8e4f9e8f8e57cf6a5d81341bc239ead6732332e Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 3 Apr 2014 16:14:58 -0500 Subject: [PATCH] HHH-8956 - TLC for annotation pre-processor + document AccessType as topical guide --- .../access/jpa/AccessMappingTest.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java index 1f52fd5f78..67c31e4e50 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/AccessMappingTest.java @@ -28,12 +28,13 @@ import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.Environment; import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.metamodel.MetadataSources; +import org.hibernate.metamodel.spi.LenientPersistentAttributeMemberResolver; import org.hibernate.property.BasicPropertyAccessor; import org.hibernate.property.DirectPropertyAccessor; import org.hibernate.service.ServiceRegistry; import org.hibernate.tuple.entity.EntityTuplizer; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; @@ -157,18 +158,16 @@ public void testExplicitPropertyAccessAnnotationsOnField() throws Exception { } @Test - @FailureExpectedWithNewMetamodel( - message = "No idea on 2 levels. First, how is this a 'Hibernate-style override'? " + - "Second, tbh, not even sure this should pass; doesn't the AccessType#FIELD override" + - " belong on the field? The test passes if @Access(AccessType.FIELD) and other" + - "annotations are moved from Course3#getId() to Course3#id. Message sent to hibernate-dev " + - "mailing list to get additional points of view." - ) public void testExplicitPropertyAccessAnnotationsWithHibernateStyleOverride() throws Exception { - AnnotationConfiguration cfg = new AnnotationConfiguration(); - cfg.addAnnotatedClass( Course3.class ); - cfg.addAnnotatedClass( Student.class ); - SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry ); + MetadataSources sources = new MetadataSources( serviceRegistry ); + sources.addAnnotatedClass( Course3.class ) + .addAnnotatedClass( Student.class ); + + SessionFactoryImplementor factory = (SessionFactoryImplementor) sources.getMetadataBuilder() + .with( LenientPersistentAttributeMemberResolver.INSTANCE ) + .build() + .buildSessionFactory(); + EntityTuplizer tuplizer = factory.getEntityPersister( Course3.class.getName() ) .getEntityMetamodel() .getTuplizer();