@Override public void create(boolean export, String outputFile, boolean append) { final String[] createSQL = configuration.generateSchemaCreationScript(dialect); perform(createSQL, export, outputFile, append, true); }
public String[] getCreateSql() { return configuration.generateSchemaCreationScript(getDialect()); }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateDropSchemaDDL(String dialect) { Properties props = new Properties(); props.put(Environment.DIALECT, dialect); Configuration cfg = createConfiguration(props); String[] sqls = cfg.generateSchemaCreationScript(Dialect.getDialect(props)); addDelimiters(sqls); return sqls; }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateDropSchemaDDL(String dialect) { Properties props = new Properties(); props.put(Environment.DIALECT, dialect); Configuration cfg = createConfiguration(props); String[] sqls = cfg.generateSchemaCreationScript(Dialect.getDialect(props)); addDelimiters(sqls); return sqls; }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateCreateSchemaDDL(String dialect) { Properties props = new Properties(); props.put( Environment.DIALECT, dialect); Configuration cfg = getBasicConfiguration(props); String[] sqls = cfg.generateSchemaCreationScript( Dialect.getDialect(props)); addDelimiters(sqls); return sqls; }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateCreateSchemaDDL(String dialect) { Properties props = new Properties(); props.put(Environment.DIALECT, dialect); Configuration cfg = createConfiguration(props); String[] sqls = cfg.generateSchemaCreationScript(Dialect.getDialect(props)); addDelimiters(sqls); return sqls; }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateCreateSchemaDDL(String dialect) { Properties props = new Properties(); props.put(Environment.DIALECT, dialect); Configuration cfg = createConfiguration(props); String[] sqls = cfg.generateSchemaCreationScript(Dialect.getDialect(props)); addDelimiters(sqls); return sqls; }
/** * Create a schema exporter for the given Configuration, with the given * database connection properties. */ public SchemaExport(Configuration cfg, Properties connectionProperties) throws HibernateException { dialect = Dialect.getDialect( connectionProperties ); Properties props = new Properties(); props.putAll( dialect.getDefaultProperties() ); props.putAll( connectionProperties ); connectionHelper = new ProviderConnectionHelper( props ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); exceptions = new ArrayList(); }
public SchemaExport(Configuration cfg, Connection connection) { this.connectionHelper = new SuppliedConnectionHelper( connection ); dialect = Dialect.getDialect( cfg.getProperties() ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); exceptions = new ArrayList(); }
/** * Generates the DDL schema * @param dialect the dialect to use (complete class name for the hibernate dialect object) * @return an array containing the SQL statements */ public static String[] generateCreateSchemaDDL(String dialect) { Configuration cfg = ((AbstractHibernateDataConfig) IntactContext.getCurrentInstance().getConfig().getDefaultDataConfig()).getConfiguration(); Properties props = new Properties(); props.put(Environment.DIALECT, dialect); return cfg.generateSchemaCreationScript(Dialect.getDialect(props)); }
@Override public Object doInHibernate(Session session) throws HibernateException, SQLException { Connection con = session.connection(); String[] sql = getConfiguration().generateSchemaCreationScript(dialect); executeSchemaScript(con, sql); return null; } }
/** * Create a schema exporter for the given Configuration, with the given * database connection properties. * * @deprecated properties may be specified via the Configuration object */ public SchemaExport(Configuration cfg, Properties properties) throws HibernateException { dialect = Dialect.getDialect( properties ); Properties props = new Properties(); props.putAll( dialect.getDefaultProperties() ); props.putAll( properties ); connectionHelper = new ManagedProviderConnectionHelper( props ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); format = PropertiesHelper.getBoolean( Environment.FORMAT_SQL, props ); }
public SchemaExport(Configuration cfg, Connection connection) { this.connectionHelper = new SuppliedConnectionHelper( connection ); dialect = Dialect.getDialect( cfg.getProperties() ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); }
/** * Create a schema exporter for the given Configuration * and given settings */ public SchemaExport(Configuration cfg, Settings settings) throws HibernateException { dialect = settings.getDialect(); connectionHelper = new SuppliedConnectionProviderConnectionHelper( settings.getConnectionProvider() ); dropSQL = cfg.generateDropSchemaScript( dialect ); createSQL = cfg.generateSchemaCreationScript( dialect ); format = settings.isFormatSqlEnabled(); }
public void export(OutputStream out, boolean generateCreateQueries, boolean generateDropQueries) { Dialect hibDialect = Dialect.getDialect(hibernateConfiguration.getProperties()); try (PrintWriter writer = new PrintWriter(out)) { if (generateCreateQueries) { String[] createSQL = hibernateConfiguration.generateSchemaCreationScript(hibDialect); write(writer, createSQL, FormatStyle.DDL.getFormatter()); } if (generateDropQueries) { String[] dropSQL = hibernateConfiguration.generateDropSchemaScript(hibDialect); write(writer, dropSQL, FormatStyle.DDL.getFormatter()); } } }
/** * Create a schema exporter for the given Configuration, using the supplied connection for connectivity. * * @param configuration The configuration to use. * @param connection The JDBC connection to use. * @throws HibernateException Indicates problem preparing for schema export. */ public SchemaExport(Configuration configuration, Connection connection) throws HibernateException { this.connectionHelper = new SuppliedConnectionHelper( connection ); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); this.sqlExceptionHelper = new SqlExceptionHelper(); this.importFiles = ConfigurationHelper.getString( AvailableSettings.HBM2DDL_IMPORT_FILES, configuration.getProperties(), DEFAULT_IMPORT_FILE ); final Dialect dialect = Dialect.getDialect( configuration.getProperties() ); this.dropSQL = configuration.generateDropSchemaScript( dialect ); this.createSQL = configuration.generateSchemaCreationScript( dialect ); }
/** * Create a schema exporter for the given Configuration, using the supplied connection for connectivity. * * @param configuration The configuration to use. * @param connection The JDBC connection to use. * @throws HibernateException Indicates problem preparing for schema export. */ public SchemaExport(Configuration configuration, Connection connection) throws HibernateException { this.connectionHelper = new SuppliedConnectionHelper( connection ); this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.formatter = FormatStyle.DDL.getFormatter(); this.sqlExceptionHelper = new SqlExceptionHelper(); this.importFiles = ConfigurationHelper.getString( AvailableSettings.HBM2DDL_IMPORT_FILES, configuration.getProperties(), DEFAULT_IMPORT_FILE ); final Dialect dialect = Dialect.getDialect( configuration.getProperties() ); this.dropSQL = configuration.generateDropSchemaScript( dialect ); this.createSQL = configuration.generateSchemaCreationScript( dialect ); }
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { log.debug("dropping db schema"); String[] dropScript = configuration.generateDropSchemaScript(dialect); executeScript(connection, dropScript); log.debug("creating db schema"); String[] createScript = configuration.generateSchemaCreationScript(dialect); executeScript(connection, createScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error creating schema", e); } finally { connectionProvider.close(); } }
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 ); }
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 ); }