Search in sources :

Example 16 with ServiceRegistryImplementor

use of org.hibernate.service.spi.ServiceRegistryImplementor in project hibernate-orm by hibernate.

the class IndividuallySchemaValidatorImplConnectionTest method testMissingEntityContainsUnqualifiedEntityName.

@Test
public void testMissingEntityContainsUnqualifiedEntityName() throws Exception {
    MetadataSources metadataSources = new MetadataSources(ssr);
    metadataSources.addAnnotatedClass(UnqualifiedMissingEntity.class);
    MetadataImplementor metadata = (MetadataImplementor) metadataSources.buildMetadata();
    metadata.validate();
    Map<String, Object> settings = new HashMap<>();
    ServiceRegistryImplementor serviceRegistry = (ServiceRegistryImplementor) new StandardServiceRegistryBuilder().applySettings(settings).build();
    DriverManagerConnectionProviderImpl connectionProvider = new DriverManagerConnectionProviderImpl();
    connectionProvider.configure(properties());
    final GenerationTargetToDatabase schemaGenerator = new GenerationTargetToDatabase(new DdlTransactionIsolatorTestingImpl(serviceRegistry, new JdbcConnectionAccessImpl(connectionProvider)));
    try {
        new SchemaCreatorImpl(ssr).doCreation(metadata, serviceRegistry, settings, true, schemaGenerator);
        metadataSources = new MetadataSources(ssr);
        metadataSources.addAnnotatedClass(UnqualifiedMissingEntity.class);
        metadata = (MetadataImplementor) metadataSources.buildMetadata();
        metadata.validate();
        SchemaValidator schemaValidator = new IndividuallySchemaValidatorImpl(tool, DefaultSchemaFilter.INSTANCE);
        assertFalse(connection.getAutoCommit());
        schemaValidator.doValidation(metadata, executionOptions);
        assertFalse(connection.getAutoCommit());
    } finally {
        new SchemaDropperImpl(serviceRegistry).doDrop(metadata, false, schemaGenerator);
        serviceRegistry.destroy();
        connectionProvider.stop();
    }
}
Also used : JdbcConnectionAccessImpl(org.hibernate.testing.boot.JdbcConnectionAccessImpl) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) HashMap(java.util.HashMap) MetadataSources(org.hibernate.boot.MetadataSources) SchemaValidator(org.hibernate.tool.schema.spi.SchemaValidator) IndividuallySchemaValidatorImpl(org.hibernate.tool.schema.internal.IndividuallySchemaValidatorImpl) MetadataImplementor(org.hibernate.boot.spi.MetadataImplementor) ServiceRegistryImplementor(org.hibernate.service.spi.ServiceRegistryImplementor) DriverManagerConnectionProviderImpl(org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl) DdlTransactionIsolatorTestingImpl(org.hibernate.test.util.DdlTransactionIsolatorTestingImpl) SchemaCreatorImpl(org.hibernate.tool.schema.internal.SchemaCreatorImpl) SchemaDropperImpl(org.hibernate.tool.schema.internal.SchemaDropperImpl) GenerationTargetToDatabase(org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase) Test(org.junit.Test)

Aggregations

ServiceRegistryImplementor (org.hibernate.service.spi.ServiceRegistryImplementor)16 MetadataSources (org.hibernate.boot.MetadataSources)15 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)15 Test (org.junit.Test)13 Metadata (org.hibernate.boot.Metadata)10 Triggerable (org.hibernate.testing.logger.Triggerable)8 HashMap (java.util.HashMap)6 Session (org.hibernate.Session)6 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)6 TestForIssue (org.hibernate.testing.TestForIssue)6 DdlTransactionIsolatorTestingImpl (org.hibernate.test.util.DdlTransactionIsolatorTestingImpl)5 SchemaCreatorImpl (org.hibernate.tool.schema.internal.SchemaCreatorImpl)5 SchemaDropperImpl (org.hibernate.tool.schema.internal.SchemaDropperImpl)5 GenerationTargetToDatabase (org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase)5 Map (java.util.Map)3 MetadataImplementor (org.hibernate.boot.spi.MetadataImplementor)3 DriverManagerConnectionProviderImpl (org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl)3 JdbcConnectionAccessImpl (org.hibernate.testing.boot.JdbcConnectionAccessImpl)3 CachingRegionFactory (org.hibernate.testing.cache.CachingRegionFactory)3 SessionFactoryBuilder (org.hibernate.boot.SessionFactoryBuilder)2