use of org.hibernate.boot.registry.internal.StandardServiceRegistryImpl in project hibernate-orm by hibernate.
the class ServiceBootstrappingTest method testBuildWithLogging.
@Test
public void testBuildWithLogging() {
Properties props = ConnectionProviderBuilder.getConnectionProviderProperties();
props.put(Environment.SHOW_SQL, "true");
StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings(props).build();
try {
JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
final ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(ConnectionProviderJdbcConnectionAccess.class, jdbcServices.getBootstrapJdbcConnectionAccess());
assertTrue(connectionAccess.getConnectionProvider().isUnwrappableAs(DriverManagerConnectionProviderImpl.class));
assertTrue(jdbcServices.getSqlStatementLogger().isLogToStdout());
} finally {
serviceRegistry.destroy();
}
}
use of org.hibernate.boot.registry.internal.StandardServiceRegistryImpl in project hibernate-orm by hibernate.
the class ServiceBootstrappingTest method testBasicBuild.
@Test
public void testBasicBuild() {
// this test requires that SHOW_SQL property isn't passed from the outside (eg. via Gradle)
final String showSqlPropertyFromOutside = System.getProperty(Environment.SHOW_SQL);
Assume.assumeFalse("true".equals(showSqlPropertyFromOutside));
final StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl) new StandardServiceRegistryBuilder().applySettings(ConnectionProviderBuilder.getConnectionProviderProperties()).build();
try {
final JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
assertTrue(jdbcServices.getDialect() instanceof H2Dialect);
final ConnectionProviderJdbcConnectionAccess connectionAccess = assertTyping(ConnectionProviderJdbcConnectionAccess.class, jdbcServices.getBootstrapJdbcConnectionAccess());
assertTrue(connectionAccess.getConnectionProvider().isUnwrappableAs(DriverManagerConnectionProviderImpl.class));
assertFalse(jdbcServices.getSqlStatementLogger().isLogToStdout());
} finally {
serviceRegistry.destroy();
}
}
use of org.hibernate.boot.registry.internal.StandardServiceRegistryImpl in project hibernate-orm by hibernate.
the class BaseCoreFunctionalTestCase method buildServiceRegistry.
protected StandardServiceRegistryImpl buildServiceRegistry(BootstrapServiceRegistry bootRegistry, Configuration configuration) {
Properties properties = new Properties();
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
StandardServiceRegistryBuilder cfgRegistryBuilder = configuration.getStandardServiceRegistryBuilder();
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder(bootRegistry, cfgRegistryBuilder.getAggregatedCfgXml()).applySettings(properties);
prepareBasicRegistryBuilder(registryBuilder);
return (StandardServiceRegistryImpl) registryBuilder.build();
}
use of org.hibernate.boot.registry.internal.StandardServiceRegistryImpl in project hibernate-orm by hibernate.
the class BasicHibernateAnnotationsTest method testTypeDefWithoutNameAndDefaultForTypeAttributes.
@Test
public void testTypeDefWithoutNameAndDefaultForTypeAttributes() {
SessionFactory sf = null;
StandardServiceRegistryImpl ssr = null;
try {
Configuration config = new Configuration();
config.addAnnotatedClass(LocalContactDetails.class);
ssr = ServiceRegistryBuilder.buildServiceRegistry(config.getProperties());
sf = config.buildSessionFactory(ssr);
fail("Did not throw expected exception");
} catch (AnnotationException ex) {
assertEquals("Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass org.hibernate.test.annotations.entity.PhoneNumberType", ex.getMessage());
} finally {
if (ssr != null) {
ssr.destroy();
}
if (sf != null) {
sf.close();
}
}
}
use of org.hibernate.boot.registry.internal.StandardServiceRegistryImpl in project hibernate-orm by hibernate.
the class QueryReturnTest method testQueryReturn.
@Test
public void testQueryReturn() {
StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder().applySetting("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
StandardServiceRegistry standardServiceRegistry = serviceRegistryBuilder.build();
MetadataSources metadataSources = new MetadataSources(standardServiceRegistry);
try {
metadataSources.addInputStream(new ReaderInputStream(new StringReader(QUERY_RETURN_HBM_XML)));
Metadata metadata = metadataSources.buildMetadata();
NamedSQLQueryDefinition myQuery = metadata.getNamedNativeQueryDefinition("myQuery");
Assert.assertNotNull(myQuery);
NativeSQLQueryReturn[] myQueryReturns = myQuery.getQueryReturns();
Assert.assertNotNull(myQueryReturns);
Assert.assertEquals(1, myQueryReturns.length);
Assert.assertTrue(NativeSQLQueryRootReturn.class.isInstance(myQueryReturns[0]));
NativeSQLQueryRootReturn myQueryRootReturn = (NativeSQLQueryRootReturn) myQueryReturns[0];
Assert.assertEquals("e", myQueryRootReturn.getAlias());
Assert.assertEquals("org.hibernate.test.hbm.query.QueryReturnTest$Bar", myQueryRootReturn.getReturnEntityName());
} finally {
if (standardServiceRegistry instanceof StandardServiceRegistryImpl) {
((StandardServiceRegistryImpl) standardServiceRegistry).destroy();
}
}
}
Aggregations