Search in sources :

Example 1 with DatabaseInformation

use of org.hibernate.tool.schema.extract.spi.DatabaseInformation in project hibernate-orm by hibernate.

the class AbstractSchemaMigrator method doMigration.

@Override
public void doMigration(Metadata metadata, ExecutionOptions options, TargetDescriptor targetDescriptor) {
    if (!targetDescriptor.getTargetTypes().isEmpty()) {
        final JdbcContext jdbcContext = tool.resolveJdbcContext(options.getConfigurationValues());
        final DdlTransactionIsolator ddlTransactionIsolator = tool.getDdlTransactionIsolator(jdbcContext);
        try {
            final DatabaseInformation databaseInformation = Helper.buildDatabaseInformation(tool.getServiceRegistry(), ddlTransactionIsolator, metadata.getDatabase().getDefaultNamespace().getName());
            final GenerationTarget[] targets = tool.buildGenerationTargets(targetDescriptor, ddlTransactionIsolator, options.getConfigurationValues());
            try {
                for (GenerationTarget target : targets) {
                    target.prepare();
                }
                try {
                    performMigration(metadata, databaseInformation, options, jdbcContext.getDialect(), targets);
                } finally {
                    for (GenerationTarget target : targets) {
                        try {
                            target.release();
                        } catch (Exception e) {
                            log.debugf("Problem releasing GenerationTarget [%s] : %s", target, e.getMessage());
                        }
                    }
                }
            } finally {
                try {
                    databaseInformation.cleanup();
                } catch (Exception e) {
                    log.debug("Problem releasing DatabaseInformation : " + e.getMessage());
                }
            }
        } finally {
            ddlTransactionIsolator.release();
        }
    }
}
Also used : DatabaseInformation(org.hibernate.tool.schema.extract.spi.DatabaseInformation) JdbcContext(org.hibernate.tool.schema.internal.exec.JdbcContext) GenerationTarget(org.hibernate.tool.schema.internal.exec.GenerationTarget) DdlTransactionIsolator(org.hibernate.resource.transaction.spi.DdlTransactionIsolator) CommandAcceptanceException(org.hibernate.tool.schema.spi.CommandAcceptanceException) SchemaManagementException(org.hibernate.tool.schema.spi.SchemaManagementException)

Example 2 with DatabaseInformation

use of org.hibernate.tool.schema.extract.spi.DatabaseInformation in project hibernate-orm by hibernate.

the class AbstractSchemaValidator method doValidation.

@Override
public void doValidation(Metadata metadata, ExecutionOptions options) {
    final JdbcContext jdbcContext = tool.resolveJdbcContext(options.getConfigurationValues());
    final DdlTransactionIsolator isolator = tool.getDdlTransactionIsolator(jdbcContext);
    final DatabaseInformation databaseInformation = Helper.buildDatabaseInformation(tool.getServiceRegistry(), isolator, metadata.getDatabase().getDefaultNamespace().getName());
    try {
        performValidation(metadata, databaseInformation, options, jdbcContext.getDialect());
    } finally {
        try {
            databaseInformation.cleanup();
        } catch (Exception e) {
            log.debug("Problem releasing DatabaseInformation : " + e.getMessage());
        }
        isolator.release();
    }
}
Also used : DatabaseInformation(org.hibernate.tool.schema.extract.spi.DatabaseInformation) JdbcContext(org.hibernate.tool.schema.internal.exec.JdbcContext) DdlTransactionIsolator(org.hibernate.resource.transaction.spi.DdlTransactionIsolator) SchemaManagementException(org.hibernate.tool.schema.spi.SchemaManagementException)

Example 3 with DatabaseInformation

use of org.hibernate.tool.schema.extract.spi.DatabaseInformation in project hibernate-orm by hibernate.

the class TestExtraPhysicalTableTypes method buildInformationExtractorJdbcDatabaseMetaDataImplTest.

private InformationExtractorJdbcDatabaseMetaDataImplTest buildInformationExtractorJdbcDatabaseMetaDataImplTest() throws SQLException {
    Database database = metadata.getDatabase();
    final ConnectionProvider connectionProvider = ssr.getService(ConnectionProvider.class);
    DatabaseInformation dbInfo = new DatabaseInformationImpl(ssr, database.getJdbcEnvironment(), new DdlTransactionIsolatorTestingImpl(ssr, new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess(connectionProvider)), database.getDefaultNamespace().getName());
    ExtractionContextImpl extractionContext = new ExtractionContextImpl(ssr, database.getJdbcEnvironment(), ssr.getService(JdbcServices.class).getBootstrapJdbcConnectionAccess(), (ExtractionContext.DatabaseObjectAccess) dbInfo, database.getDefaultNamespace().getPhysicalName().getCatalog(), database.getDefaultNamespace().getPhysicalName().getSchema());
    return new InformationExtractorJdbcDatabaseMetaDataImplTest(extractionContext);
}
Also used : DdlTransactionIsolatorTestingImpl(org.hibernate.test.util.DdlTransactionIsolatorTestingImpl) DatabaseInformation(org.hibernate.tool.schema.extract.spi.DatabaseInformation) ExtractionContext(org.hibernate.tool.schema.extract.spi.ExtractionContext) Database(org.hibernate.boot.model.relational.Database) DatabaseInformationImpl(org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl) ExtractionContextImpl(org.hibernate.tool.schema.extract.internal.ExtractionContextImpl) ConnectionProvider(org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)

Aggregations

DatabaseInformation (org.hibernate.tool.schema.extract.spi.DatabaseInformation)3 DdlTransactionIsolator (org.hibernate.resource.transaction.spi.DdlTransactionIsolator)2 JdbcContext (org.hibernate.tool.schema.internal.exec.JdbcContext)2 SchemaManagementException (org.hibernate.tool.schema.spi.SchemaManagementException)2 Database (org.hibernate.boot.model.relational.Database)1 ConnectionProvider (org.hibernate.engine.jdbc.connections.spi.ConnectionProvider)1 DdlTransactionIsolatorTestingImpl (org.hibernate.test.util.DdlTransactionIsolatorTestingImpl)1 DatabaseInformationImpl (org.hibernate.tool.schema.extract.internal.DatabaseInformationImpl)1 ExtractionContextImpl (org.hibernate.tool.schema.extract.internal.ExtractionContextImpl)1 ExtractionContext (org.hibernate.tool.schema.extract.spi.ExtractionContext)1 GenerationTarget (org.hibernate.tool.schema.internal.exec.GenerationTarget)1 CommandAcceptanceException (org.hibernate.tool.schema.spi.CommandAcceptanceException)1