Search in sources :

Example 1 with ImportSqlCommandExtractor

use of org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor in project hibernate-orm by hibernate.

the class SchemaCreatorImpl method performCreation.

private void performCreation(Metadata metadata, Dialect dialect, ExecutionOptions options, SourceDescriptor sourceDescriptor, GenerationTarget... targets) {
    final ImportSqlCommandExtractor commandExtractor = tool.getServiceRegistry().getService(ImportSqlCommandExtractor.class);
    final boolean format = Helper.interpretFormattingEnabled(options.getConfigurationValues());
    final Formatter formatter = format ? FormatStyle.DDL.getFormatter() : FormatStyle.NONE.getFormatter();
    switch(sourceDescriptor.getSourceType()) {
        case SCRIPT:
            {
                createFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
                break;
            }
        case METADATA:
            {
                createFromMetadata(metadata, options, dialect, formatter, targets);
                break;
            }
        case METADATA_THEN_SCRIPT:
            {
                createFromMetadata(metadata, options, dialect, formatter, targets);
                createFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
                break;
            }
        case SCRIPT_THEN_METADATA:
            {
                createFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
                createFromMetadata(metadata, options, dialect, formatter, targets);
            }
    }
    applyImportSources(options, commandExtractor, format, targets);
}
Also used : Formatter(org.hibernate.engine.jdbc.internal.Formatter) ImportSqlCommandExtractor(org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor)

Example 2 with ImportSqlCommandExtractor

use of org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor in project hibernate-orm by hibernate.

the class SchemaDropperImpl method performDrop.

private void performDrop(Metadata metadata, ExecutionOptions options, Dialect dialect, SourceDescriptor sourceDescriptor, GenerationTarget... targets) {
    final ImportSqlCommandExtractor commandExtractor = tool.getServiceRegistry().getService(ImportSqlCommandExtractor.class);
    final boolean format = Helper.interpretFormattingEnabled(options.getConfigurationValues());
    final Formatter formatter = format ? FormatStyle.DDL.getFormatter() : FormatStyle.NONE.getFormatter();
    if (sourceDescriptor.getSourceType() == SourceType.SCRIPT) {
        dropFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
    } else if (sourceDescriptor.getSourceType() == SourceType.METADATA) {
        dropFromMetadata(metadata, options, dialect, formatter, targets);
    } else if (sourceDescriptor.getSourceType() == SourceType.METADATA_THEN_SCRIPT) {
        dropFromMetadata(metadata, options, dialect, formatter, targets);
        dropFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
    } else {
        dropFromScript(sourceDescriptor.getScriptSourceInput(), commandExtractor, formatter, options, targets);
        dropFromMetadata(metadata, options, dialect, formatter, targets);
    }
}
Also used : Formatter(org.hibernate.engine.jdbc.internal.Formatter) ImportSqlCommandExtractor(org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor)

Aggregations

Formatter (org.hibernate.engine.jdbc.internal.Formatter)2 ImportSqlCommandExtractor (org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor)2