use of org.hibernate.service.ServiceRegistryBuilder 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.service.ServiceRegistryBuilder in project ignite by apache.
the class HibernateL2CacheSelfTest method startHibernate.
/**
* Starts Hibernate.
*
* @param accessType Cache access type.
* @param igniteInstanceName Ignite instance name.
* @return Session factory.
*/
private SessionFactory startHibernate(AccessType accessType, String igniteInstanceName) {
Configuration cfg = hibernateConfiguration(accessType, igniteInstanceName);
ServiceRegistryBuilder builder = registryBuilder();
builder.applySetting("hibernate.show_sql", false);
return cfg.buildSessionFactory(builder.buildServiceRegistry());
}
use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class ConfigurationFacadeImpl method buildServiceRegistry.
private ServiceRegistry buildServiceRegistry() {
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(((Configuration) getTarget()).getProperties());
return builder.buildServiceRegistry();
}
use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class ServiceImpl method buildServiceRegistry.
private ServiceRegistry buildServiceRegistry(IConfiguration configuration) {
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
return builder.buildServiceRegistry();
}
use of org.hibernate.service.ServiceRegistryBuilder 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