use of org.hibernate.tuple.entity.EntityTuplizer in project hibernate-orm by hibernate.
the class AccessMappingTest method testDefaultPropertyAccessIsInherited.
@Test
public void testDefaultPropertyAccessIsInherited() throws Exception {
Configuration cfg = new Configuration();
cfg.addAnnotatedClass(Horse.class);
cfg.addAnnotatedClass(Animal.class);
SessionFactoryImplementor factory = (SessionFactoryImplementor) cfg.buildSessionFactory(serviceRegistry);
try {
EntityTuplizer tuplizer = factory.getEntityPersister(Animal.class.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Property access should be used since explicity configured via @Access", tuplizer.getIdentifierGetter() instanceof GetterMethodImpl);
tuplizer = factory.getEntityPersister(Horse.class.getName()).getEntityMetamodel().getTuplizer();
assertTrue("Field access should be used since the default access mode gets inherited", tuplizer.getGetter(0) instanceof GetterFieldImpl);
} 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();
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);
}
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");
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.build();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
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, null, sfi) {
@Override
public EntityTuplizer getTuplizer() {
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 AbstractEntityMetamodelFacade(FACADE_FACTORY, entityMetamodel) {
};
}
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");
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.buildServiceRegistry();
org.hibernate.engine.spi.SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
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() {
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 AbstractEntityMetamodelFacade(FACADE_FACTORY, entityMetamodel) {
};
}
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");
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.build();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
RootClass rc = new RootClass(null);
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);
MetadataImplementor m = (MetadataImplementor) MetadataHelper.getMetadata(configuration);
SimpleValue sv = new SimpleValue(m);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.addColumn(c);
rc.setEntityName("foobar");
rc.setIdentifier(sv);
entityMetamodel = new EntityMetamodel(rc, null, sfi) {
@Override
public EntityTuplizer getTuplizer() {
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 AbstractEntityMetamodelFacade(FACADE_FACTORY, entityMetamodel) {
};
}
Aggregations