Example #1
0
  public SchemaExport(MetadataImplementor metadata) {
    ServiceRegistry serviceRegistry = metadata.getServiceRegistry();
    this.connectionHelper =
        new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService(ConnectionProvider.class));
    JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter =
        (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
    this.sqlExceptionHelper = jdbcServices.getSqlExceptionHelper();

    this.importFiles =
        ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            serviceRegistry.getService(ConfigurationService.class).getSettings(),
            DEFAULT_IMPORT_FILE);

    final Dialect dialect = jdbcServices.getDialect();
    this.dropSQL = metadata.getDatabase().generateDropSchemaScript(dialect);
    this.createSQL = metadata.getDatabase().generateSchemaCreationScript(dialect);
  }
Example #2
0
 private void perform(String[] sqlCommands, List<Exporter> exporters) {
   for (String sqlCommand : sqlCommands) {
     String formatted = formatter.format(sqlCommand);
     if (delimiter != null) {
       formatted += delimiter;
     }
     sqlStatementLogger.logStatement(sqlCommand, formatter);
     for (Exporter exporter : exporters) {
       try {
         exporter.export(formatted);
       } catch (Exception e) {
         if (haltOnError) {
           throw new HibernateException("Error during DDL export", e);
         }
         exceptions.add(e);
         LOG.unsuccessfulCreate(sqlCommand);
         LOG.error(e.getMessage());
       }
     }
   }
 }
Example #3
0
  public SchemaExport(ServiceRegistry serviceRegistry, Configuration configuration) {
    this.connectionHelper =
        new SuppliedConnectionProviderConnectionHelper(
            serviceRegistry.getService(ConnectionProvider.class));
    this.sqlStatementLogger =
        serviceRegistry.getService(JdbcServices.class).getSqlStatementLogger();
    this.formatter =
        (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
    this.sqlExceptionHelper =
        serviceRegistry.getService(JdbcServices.class).getSqlExceptionHelper();

    this.importFiles =
        ConfigurationHelper.getString(
            AvailableSettings.HBM2DDL_IMPORT_FILES,
            configuration.getProperties(),
            DEFAULT_IMPORT_FILE);

    final Dialect dialect = serviceRegistry.getService(JdbcServices.class).getDialect();
    this.dropSQL = configuration.generateDropSchemaScript(dialect);
    this.createSQL = configuration.generateSchemaCreationScript(dialect);
  }