use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class SchemaExport method createServiceRegistry.
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings(properties).buildServiceRegistry();
}
use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class ColumnFacadeImpl method getSqlType.
@Override
public String getSqlType(IConfiguration configuration) {
Column targetColumn = (Column) getTarget();
Configuration configurationTarget = (Configuration) ((IFacade) configuration).getTarget();
Properties properties = configurationTarget.getProperties();
ServiceRegistryBuilder ssrb = new ServiceRegistryBuilder();
ssrb.applySettings(properties);
ServiceRegistry ssr = ssrb.buildServiceRegistry();
DialectFactory df = ssr.getService(DialectFactory.class);
Dialect dialectTarget = df.buildDialect(properties, null);
return targetColumn.getSqlType(dialectTarget, configurationTarget.buildMapping());
}
use of org.hibernate.service.ServiceRegistryBuilder 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.setIdentifier(sv);
rc.setTable(t);
mappings.addClass(rc);
ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
builder.applySettings(configuration.getProperties());
ServiceRegistry serviceRegistry = builder.buildServiceRegistry();
SessionFactoryImplementor sfi = (SessionFactoryImplementor) configuration.buildSessionFactory(serviceRegistry);
HQLQueryPlan hqlQueryPlan = new HQLQueryPlan("from foo", false, Collections.emptyMap(), sfi);
IHQLQueryPlan facade = facadeFactory.createHQLQueryPlan(hqlQueryPlan);
Assert.assertSame(hqlQueryPlan, ((IFacade) facade).getTarget());
}
use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testOpenSession.
@Test
public void testOpenSession() {
Configuration configuration = new Configuration();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
ISession sessionFacade = sessionFactoryFacade.openSession();
Session session = (Session) ((IFacade) sessionFacade).getTarget();
Assert.assertSame(sessionFactory, session.getSessionFactory());
}
use of org.hibernate.service.ServiceRegistryBuilder in project jbosstools-hibernate by jbosstools.
the class SessionFactoryFacadeTest method testGetClassMetadata.
@Test
public void testGetClassMetadata() {
Configuration configuration = new Configuration();
configuration.addClass(Foo.class);
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
ClassMetadata classMetadata = sessionFactory.getClassMetadata(Foo.class);
ISessionFactory sessionFactoryFacade = FACADE_FACTORY.createSessionFactory(sessionFactory);
Assert.assertSame(classMetadata, ((IFacade) sessionFactoryFacade.getClassMetadata(Foo.class)).getTarget());
Assert.assertSame(classMetadata, ((IFacade) sessionFactoryFacade.getClassMetadata("org.jboss.tools.hibernate.runtime.v_4_0.internal.test.Foo")).getTarget());
}
Aggregations