use of org.hibernate.cfg.Mappings in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateHQLQueryPlan.
@Test
public void testCreateHQLQueryPlan() {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
Mappings mappings = configuration.createMappings();
Table t = new Table("FOO");
Column c = new Column("foo");
t.addColumn(c);
PrimaryKey key = new PrimaryKey();
key.addColumn(c);
t.setPrimaryKey(key);
Mappings m = configuration.createMappings();
SimpleValue sv = new SimpleValue(m);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
sv.setTable(t);
sv.addColumn(c);
RootClass rc = new RootClass();
rc.setEntityName("foo");
rc.setJpaEntityName("foo");
rc.setIdentifier(sv);
rc.setTable(t);
mappings.addClass(rc);
StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.build();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
Map<String, Filter> filters = Collections.emptyMap();
HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, filters, sfi);
IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
Assert.assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
use of org.hibernate.cfg.Mappings in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateEntityMetamodel.
@Test
public void testCreateEntityMetamodel() {
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();
Mappings m = configuration.createMappings();
SimpleValue sv = new SimpleValue(m);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
rc.setIdentifier(sv);
EntityMetamodel entityMetamodel = new EntityMetamodel(rc, null, sfi);
IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
use of org.hibernate.cfg.Mappings in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method testGetPropertyTag.
public void testGetPropertyTag() throws Exception {
RootClass rc = new RootClass();
Property p = new Property();
Mappings m = (Mappings) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { Mappings.class }, new TestInvocationHandler());
SimpleValue sv = new SimpleValue(m);
sv.setTypeName("foobar");
p.setValue(sv);
p.setPersistentClass(rc);
rc.setVersion(p);
IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
};
Assert.assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
use of org.hibernate.cfg.Mappings in project jbosstools-hibernate by jbosstools.
the class Cfg2HbmToolFacadeTest method testGetPropertyTag.
public void testGetPropertyTag() throws Exception {
RootClass rc = new RootClass();
Property p = new Property();
Mappings m = (Mappings) Proxy.newProxyInstance(FACADE_FACTORY.getClassLoader(), new Class[] { Mappings.class }, new TestInvocationHandler());
SimpleValue sv = new SimpleValue(m);
sv.setTypeName("foobar");
p.setValue(sv);
p.setPersistentClass(rc);
rc.setVersion(p);
IProperty property = new AbstractPropertyFacade(FACADE_FACTORY, p) {
};
Assert.assertEquals("version", cfg2HbmToolFacade.getTag(property));
}
use of org.hibernate.cfg.Mappings in project jbosstools-hibernate by jbosstools.
the class FacadeFactoryTest method testCreateEntityMetamodel.
@Test
public void testCreateEntityMetamodel() {
Configuration configuration = new Configuration();
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.buildServiceRegistry();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
RootClass rc = new RootClass();
Mappings m = configuration.createMappings();
SimpleValue sv = new SimpleValue(m);
sv.setNullValue("null");
sv.setTypeName(Integer.class.getName());
rc.setIdentifier(sv);
EntityMetamodel entityMetamodel = new EntityMetamodel(rc, sfi);
IEntityMetamodel facade = facadeFactory.createEntityMetamodel(entityMetamodel);
Assert.assertSame(entityMetamodel, ((IFacade) facade).getTarget());
}
Aggregations