use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project hibernate-orm by hibernate.
the class NoDatabaseMetaDataTest method testNoJdbcMetadataDefaultDialect.
@Test
@TestForIssue(jiraKey = "HHH-10515")
public void testNoJdbcMetadataDefaultDialect() {
final StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySetting("hibernate.temp.use_jdbc_metadata_defaults", "false").build();
JdbcEnvironment jdbcEnvironment = serviceRegistry.getService(JdbcEnvironment.class);
ExtractedDatabaseMetaData extractedDatabaseMetaData = jdbcEnvironment.getExtractedDatabaseMetaData();
assertNull(extractedDatabaseMetaData.getConnectionCatalogName());
assertNull(extractedDatabaseMetaData.getConnectionSchemaName());
assertTrue(extractedDatabaseMetaData.getTypeInfoSet().isEmpty());
assertTrue(extractedDatabaseMetaData.getExtraKeywords().isEmpty());
assertFalse(extractedDatabaseMetaData.supportsNamedParameters());
assertFalse(extractedDatabaseMetaData.supportsRefCursors());
assertFalse(extractedDatabaseMetaData.supportsScrollableResults());
assertFalse(extractedDatabaseMetaData.supportsGetGeneratedKeys());
assertFalse(extractedDatabaseMetaData.supportsBatchUpdates());
assertFalse(extractedDatabaseMetaData.supportsDataDefinitionInTransaction());
assertFalse(extractedDatabaseMetaData.doesDataDefinitionCauseTransactionCommit());
assertNull(extractedDatabaseMetaData.getSqlStateType());
assertFalse(extractedDatabaseMetaData.doesLobLocatorUpdateCopy());
StandardServiceRegistryBuilder.destroy(serviceRegistry);
}
use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project hibernate-orm by hibernate.
the class ConfigurationValidationTest method testInvalidConnectionProvider.
@Test(expected = ServiceException.class)
public void testInvalidConnectionProvider() {
ServiceRegistryImplementor serviceRegistry = null;
try {
serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySetting(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA).applySetting(Environment.MULTI_TENANT_CONNECTION_PROVIDER, "class.not.present.in.classpath").build();
new MetadataSources(serviceRegistry).buildMetadata().buildSessionFactory().close();
} finally {
if (serviceRegistry != null) {
try {
StandardServiceRegistryBuilder.destroy(serviceRegistry);
} catch (Exception ignore) {
}
}
}
}
use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project hibernate-orm by hibernate.
the class SchemaBasedMultiTenancyTest method setUp.
@Before
public void setUp() {
AbstractMultiTenantConnectionProvider multiTenantConnectionProvider = buildMultiTenantConnectionProvider();
Map settings = new HashMap();
settings.put(Environment.MULTI_TENANT, MultiTenancyStrategy.SCHEMA);
settings.put(Environment.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName());
settings.put(Environment.GENERATE_STATISTICS, "true");
serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySettings(settings).addService(MultiTenantConnectionProvider.class, multiTenantConnectionProvider).build();
MetadataSources ms = new MetadataSources(serviceRegistry);
ms.addAnnotatedClass(Customer.class);
ms.addAnnotatedClass(Invoice.class);
Metadata metadata = ms.buildMetadata();
((RootClass) metadata.getEntityBinding(Customer.class.getName())).setCacheConcurrencyStrategy("read-write");
HibernateSchemaManagementTool tool = new HibernateSchemaManagementTool();
tool.injectServices(serviceRegistry);
final GenerationTargetToDatabase acmeTarget = new GenerationTargetToDatabase(new DdlTransactionIsolatorTestingImpl(serviceRegistry, acmeProvider));
final GenerationTargetToDatabase jbossTarget = new GenerationTargetToDatabase(new DdlTransactionIsolatorTestingImpl(serviceRegistry, jbossProvider));
new SchemaDropperImpl(serviceRegistry).doDrop(metadata, serviceRegistry, settings, true, acmeTarget, jbossTarget);
new SchemaCreatorImpl(serviceRegistry).doCreation(metadata, serviceRegistry, settings, true, acmeTarget, jbossTarget);
final SessionFactoryBuilder sfb = metadata.getSessionFactoryBuilder();
configure(sfb);
sessionFactory = (SessionFactoryImplementor) sfb.build();
}
use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project hibernate-orm by hibernate.
the class PersistentClassVisitorTest method prepare.
@Before
public void prepare() {
serviceRegistry = new StandardServiceRegistryBuilder().build();
metadataBuildingContext = new MetadataBuildingContextTestingImpl(serviceRegistry);
}
use of org.hibernate.boot.registry.StandardServiceRegistryBuilder in project hibernate-orm by hibernate.
the class ValueVisitorTest method prepare.
@Before
public void prepare() {
serviceRegistry = new StandardServiceRegistryBuilder().build();
metadataBuildingContext = new MetadataBuildingContextTestingImpl(serviceRegistry);
}
Aggregations