Search in sources :

Example 6 with GetterFieldImpl

use of org.hibernate.property.access.spi.GetterFieldImpl in project hibernate-orm by hibernate.

the class AccessMappingTest method testDefaultFieldAccessIsInherited.

@Test
public void testDefaultFieldAccessIsInherited() throws Exception {
    Configuration cfg = new Configuration();
    Class<?> classUnderTest = User.class;
    cfg.addAnnotatedClass(classUnderTest);
    cfg.addAnnotatedClass(Person.class);
    cfg.addAnnotatedClass(Being.class);
    SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
    try {
        EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
        assertTrue("Field access should be used since the default access mode gets inherited", tuplizer.getIdentifierGetter() instanceof GetterFieldImpl);
    } finally {
        factory.close();
    }
}
Also used : EntityTuplizer(org.hibernate.tuple.entity.EntityTuplizer) GetterFieldImpl(org.hibernate.property.access.spi.GetterFieldImpl) Configuration(org.hibernate.cfg.Configuration) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) Test(org.junit.Test)

Example 7 with GetterFieldImpl

use of org.hibernate.property.access.spi.GetterFieldImpl in project hibernate-orm by hibernate.

the class AccessMappingTest method testExplicitPropertyAccessAnnotationsWithJpaStyleOverride.

@Test
public void testExplicitPropertyAccessAnnotationsWithJpaStyleOverride() throws Exception {
    Configuration cfg = new Configuration();
    Class<?> classUnderTest = Course5.class;
    cfg.addAnnotatedClass(classUnderTest);
    cfg.addAnnotatedClass(Student.class);
    SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
    try {
        EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
        assertTrue("Field access should be used.", tuplizer.getIdentifierGetter() instanceof GetterFieldImpl);
        assertTrue("Property access should be used.", tuplizer.getGetter(0) instanceof GetterMethodImpl);
    } finally {
        factory.close();
    }
}
Also used : EntityTuplizer(org.hibernate.tuple.entity.EntityTuplizer) GetterFieldImpl(org.hibernate.property.access.spi.GetterFieldImpl) Configuration(org.hibernate.cfg.Configuration) SessionFactoryImplementor(org.hibernate.engine.spi.SessionFactoryImplementor) GetterMethodImpl(org.hibernate.property.access.spi.GetterMethodImpl) Test(org.junit.Test)

Aggregations

GetterFieldImpl (org.hibernate.property.access.spi.GetterFieldImpl)7 Test (org.junit.Test)7 Configuration (org.hibernate.cfg.Configuration)5 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)5 EntityTuplizer (org.hibernate.tuple.entity.EntityTuplizer)5 GetterMethodImpl (org.hibernate.property.access.spi.GetterMethodImpl)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 Getter (org.hibernate.property.access.spi.Getter)2 AnEntity (org.hibernate.serialization.entity.AnEntity)2 PK (org.hibernate.serialization.entity.PK)2 TestForIssue (org.hibernate.testing.TestForIssue)2 Setter (org.hibernate.property.access.spi.Setter)1 SetterFieldImpl (org.hibernate.property.access.spi.SetterFieldImpl)1