Search in sources :

Example 36 with StandardServiceRegistryBuilder

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);
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) JdbcEnvironment(org.hibernate.engine.jdbc.env.spi.JdbcEnvironment) StandardServiceRegistry(org.hibernate.boot.registry.StandardServiceRegistry) ExtractedDatabaseMetaData(org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData) Test(org.junit.Test) TestForIssue(org.hibernate.testing.TestForIssue)

Example 37 with StandardServiceRegistryBuilder

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) {
            }
        }
    }
}
Also used : StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) MetadataSources(org.hibernate.boot.MetadataSources) ServiceRegistryImplementor(org.hibernate.service.spi.ServiceRegistryImplementor) ServiceException(org.hibernate.service.spi.ServiceException) Test(org.junit.Test)

Example 38 with StandardServiceRegistryBuilder

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();
}
Also used : RootClass(org.hibernate.mapping.RootClass) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) HashMap(java.util.HashMap) CachingRegionFactory(org.hibernate.testing.cache.CachingRegionFactory) MetadataSources(org.hibernate.boot.MetadataSources) Metadata(org.hibernate.boot.Metadata) AbstractMultiTenantConnectionProvider(org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider) HibernateSchemaManagementTool(org.hibernate.tool.schema.internal.HibernateSchemaManagementTool) DdlTransactionIsolatorTestingImpl(org.hibernate.test.util.DdlTransactionIsolatorTestingImpl) SchemaDropperImpl(org.hibernate.tool.schema.internal.SchemaDropperImpl) SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) SessionFactoryBuilder(org.hibernate.boot.SessionFactoryBuilder) AbstractMultiTenantConnectionProvider(org.hibernate.engine.jdbc.connections.spi.AbstractMultiTenantConnectionProvider) MultiTenantConnectionProvider(org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider) GenerationTargetToDatabase(org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase) HashMap(java.util.HashMap) Map(java.util.Map) Before(org.junit.Before)

Example 39 with StandardServiceRegistryBuilder

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);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Before(org.junit.Before)

Example 40 with StandardServiceRegistryBuilder

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);
}
Also used : MetadataBuildingContextTestingImpl(org.hibernate.testing.boot.MetadataBuildingContextTestingImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) Before(org.junit.Before)

Aggregations

StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)167 MetadataSources (org.hibernate.boot.MetadataSources)106 StandardServiceRegistry (org.hibernate.boot.registry.StandardServiceRegistry)94 Test (org.junit.Test)92 Metadata (org.hibernate.boot.Metadata)46 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)34 PersistentClass (org.hibernate.mapping.PersistentClass)27 Before (org.junit.Before)26 Properties (java.util.Properties)24 TestForIssue (org.hibernate.testing.TestForIssue)23 SchemaExport (org.hibernate.tool.hbm2ddl.SchemaExport)17 SessionFactory (org.hibernate.SessionFactory)15 BootstrapServiceRegistryBuilder (org.hibernate.boot.registry.BootstrapServiceRegistryBuilder)14 Property (org.hibernate.mapping.Property)14 SchemaUpdate (org.hibernate.tool.hbm2ddl.SchemaUpdate)14 File (java.io.File)13 BootstrapServiceRegistry (org.hibernate.boot.registry.BootstrapServiceRegistry)13 Map (java.util.Map)12 HashMap (java.util.HashMap)11 ServiceRegistry (org.hibernate.service.ServiceRegistry)11