use of org.hibernate.tuple.entity.EntityTuplizer in project hibernate-orm by hibernate.
the class AccessMappingTest method testExplicitPropertyAccessAnnotationsOnProperty.
@Test
public void testExplicitPropertyAccessAnnotationsOnProperty() throws Exception {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course2.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Property access should be used.", tuplizer.getIdentifierGetter() instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
use of org.hibernate.tuple.entity.EntityTuplizer in project hibernate-orm by hibernate.
the class AccessMappingTest method testPropertyAnnotationPlacement.
@Test
public void testPropertyAnnotationPlacement() throws Exception {
Configuration cfg = new Configuration();
Class<?> classUnderTest = Course7.class;
cfg.addAnnotatedClass(classUnderTest);
cfg.addAnnotatedClass(Student.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(classUnderTest.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Property access should be used.", tuplizer.getIdentifierGetter() instanceof GetterMethodImpl);
} finally {
factory.close();
}
}
use of org.hibernate.tuple.entity.EntityTuplizer 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();
}
}
use of org.hibernate.tuple.entity.EntityTuplizer 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();
}
}
use of org.hibernate.tuple.entity.EntityTuplizer in project jbosstools-hibernate by jbosstools.
the class EntityMetamodelFacadeTest method setUp.
@SuppressWarnings("serial")
@Before
public void setUp() throws Exception {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
SessionFactoryImplementor sfi = new SessionFactoryImpl(configuration, null, configuration.buildSettings(), null, null);
RootClass rc = new RootClass();
Table t = new Table("foobar");
rc.setTable(t);
Column c = new Column("foo");
t.addColumn(c);
ArrayList<Column> keyList = new ArrayList<>();
keyList.add(c);
t.createUniqueKey(keyList);
SimpleValue sv = new SimpleValue(configuration.createMappings());
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.addColumn(c);
rc.setEntityName("foobar");
rc.setIdentifier(sv);
entityMetamodel = new EntityMetamodel(rc, sfi) {
@Override
public EntityTuplizer getTuplizer(EntityMode entityMode) {
return (EntityTuplizer) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { EntityTuplizer.class }, new TestInvocationHandler());
}
@Override
public Integer getPropertyIndexOrNull(String id) {
methodName = "getPropertyIndexOrNull";
arguments = new Object[] { id };
return INDEX;
}
};
entityMetamodelFacade = new EntityMetamodelFacadeImpl(FACADE_FACTORY, entityMetamodel);
}
Aggregations