use of org.jboss.tools.hibernate.runtime.common.AbstractEntityMetamodelFacade 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