Java 类org.hibernate.engine.jdbc.internal.FormatStyle 实例源码

项目:lams    文件:SchemaExport.java   
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 );
}
项目:lams    文件:SchemaExport.java   
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 );
}
项目:lams    文件:SchemaExport.java   
/**
 * Create a schema exporter for the given Configuration, with the given
 * database connection properties.
 *
 * @param configuration The configuration from which to build a schema export.
 * @param properties The properties from which to configure connectivity etc.
 * @throws HibernateException Indicates problem preparing for schema export.
 *
 * @deprecated properties may be specified via the Configuration object
 */
@Deprecated
   public SchemaExport(Configuration configuration, Properties properties) throws HibernateException {
    final Dialect dialect = Dialect.getDialect( properties );

    Properties props = new Properties();
    props.putAll( dialect.getDefaultProperties() );
    props.putAll( properties );
    this.connectionHelper = new ManagedProviderConnectionHelper( props );

    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.formatter = FormatStyle.DDL.getFormatter();
    this.sqlExceptionHelper = new SqlExceptionHelper();

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

    this.dropSQL = configuration.generateDropSchemaScript( dialect );
    this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
项目:lams    文件:SchemaExport.java   
/**
 * 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 );
}
项目:lightmare    文件:TableGeneratorExt.java   
/**
 * Makes insert of last value of identifier
 * 
 * @param connection
 * @param value
 * @throws SQLException
 */
private void insert(Connection connection, IntegralDataTypeHolder value)
    throws SQLException {

    PreparedStatement insertPS = null;
    try {
    statementLogger.logStatement(insertQuery,
        FormatStyle.BASIC.getFormatter());
    insertPS = connection.prepareStatement(insertQuery);
    insertPS.setString(FIRST_COLUMN, segmentValue);
    value.bind(insertPS, SECOND_COLUMN);
    insertPS.execute();
    } finally {
    close(insertPS);
    }
}
项目:lightmare    文件:TableGeneratorExt.java   
@Override
public IntegralDataTypeHolder execute(Connection connection)
    throws SQLException {
    IntegralDataTypeHolder value = IdentifierGeneratorHelper
        .getIntegralDataTypeHolder(identifierType
            .getReturnedClass());
    int rows;
    do {
    statementLogger.logStatement(selectQuery,
        FormatStyle.BASIC.getFormatter());
    onSelect(connection, value);
    statementLogger.logStatement(updateQuery,
        FormatStyle.BASIC.getFormatter());
    rows = onUpdate(connection, value);
    } while (rows == ZERO_ROWS);

    return value;
}
项目:lams    文件:SchemaExport.java   
public SchemaExport(
        ConnectionHelper connectionHelper,
        String[] dropSql,
        String[] createSql) {
    this.connectionHelper = connectionHelper;
    this.dropSQL = dropSql;
    this.createSQL = createSql;
    this.importFiles = "";
    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.sqlExceptionHelper = new SqlExceptionHelper();
    this.formatter = FormatStyle.DDL.getFormatter();
}
项目:lams    文件:SchemaUpdate.java   
public SchemaUpdate(Configuration configuration, Properties properties) throws HibernateException {
    this.configuration = configuration;
    this.dialect = Dialect.getDialect( properties );

    Properties props = new Properties();
    props.putAll( dialect.getDefaultProperties() );
    props.putAll( properties );
    this.connectionHelper = new ManagedProviderConnectionHelper( props );

    this.sqlExceptionHelper = new SqlExceptionHelper();
    this.sqlStatementLogger = new SqlStatementLogger( false, true );
    this.formatter = FormatStyle.DDL.getFormatter();
}
项目:lams    文件:SchemaUpdate.java   
public SchemaUpdate(ServiceRegistry serviceRegistry, Configuration cfg) throws HibernateException {
    this.configuration = cfg;

    final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class );
    this.dialect = jdbcServices.getDialect();
    this.connectionHelper = new SuppliedConnectionProviderConnectionHelper( jdbcServices.getConnectionProvider() );

    this.sqlExceptionHelper = new SqlExceptionHelper();
    this.sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    this.formatter = ( sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
}
项目:lams    文件:TableGenerator.java   
private PreparedStatement prepareStatement(
        Connection connection,
        String sql,
        SqlStatementLogger statementLogger,
        SessionEventListenerManager statsCollector) throws SQLException {
    statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
    try {
        statsCollector.jdbcPrepareStatementStart();
        return connection.prepareStatement( sql );
    }
    finally {
        statsCollector.jdbcPrepareStatementEnd();
    }
}
项目:lams    文件:TableStructure.java   
private PreparedStatement prepareStatement(
        Connection connection,
        String sql,
        SqlStatementLogger statementLogger,
        SessionEventListenerManager statsCollector) throws SQLException {
    statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
    try {
        statsCollector.jdbcPrepareStatementStart();
        return connection.prepareStatement( sql );
    }
    finally {
        statsCollector.jdbcPrepareStatementEnd();
    }
}
项目:lams    文件:TableGenerator.java   
private PreparedStatement prepareStatement(
        Connection connection,
        String sql,
        SqlStatementLogger statementLogger,
        SessionEventListenerManager statsCollector) throws SQLException {
    statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
    try {
        statsCollector.jdbcPrepareStatementStart();
        return connection.prepareStatement( sql );
    }
    finally {
        statsCollector.jdbcPrepareStatementEnd();
    }
}
项目:lams    文件:MultipleHiLoPerTableGenerator.java   
private PreparedStatement prepareStatement(
        Connection connection,
        String sql,
        SqlStatementLogger statementLogger,
        SessionEventListenerManager statsCollector) throws SQLException {
    statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
    try {
        statsCollector.jdbcPrepareStatementStart();
        return connection.prepareStatement( sql );
    }
    finally {
        statsCollector.jdbcPrepareStatementEnd();
    }
}
项目:ds4p    文件:PersistenceXmlConfigSchemaExporter.java   
public static void main(String[] args) {
    boolean drop = false;
    boolean create = false;
    String outFile = null;
    String delimiter = "";
    String persistenceUnitName = null;

    for (int i = 0; i < args.length; i++) {
        if (args[i].startsWith("--")) {
            if (args[i].equals("--drop")) {
                drop = true;
            } else if (args[i].equals("--create")) {
                create = true;
            } else if (args[i].startsWith("--output=")) {
                outFile = args[i].substring(9);
            } else if (args[i].startsWith("--delimiter=")) {
                delimiter = args[i].substring(12);
            } else if (args[i].startsWith("--persistenceUnitName=")){
                persistenceUnitName = args[i].substring(22);
            }
        }
    }

    Formatter formatter = FormatStyle.DDL.getFormatter();

    Ejb3Configuration jpaConfiguration = new Ejb3Configuration().configure(
            persistenceUnitName, null);

    SchemaExporter.export(jpaConfiguration, drop, create, outFile, delimiter, formatter);
}
项目:books    文件:DbOpenHelper.java   
public DbOpenHelper(ServiceRegistry serviceRegistry) throws HibernateException {
    final JdbcServices jdbcServices = serviceRegistry.getService(JdbcServices.class);
    connectionHelper = new SuppliedConnectionProviderConnectionHelper(jdbcServices.getConnectionProvider());

    sqlStatementLogger = jdbcServices.getSqlStatementLogger();
    formatter = (sqlStatementLogger.isFormat() ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
}
项目:lams    文件:SchemaUpdate.java   
public void setFormat(boolean format) {
    this.formatter = ( format ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
}
项目:ds4p    文件:SpringEntityManagerFactoryBeanConfigSchemaExporter.java   
public static void main(String[] args) {
    boolean drop = false;
    boolean create = false;
    String outFile = null;
    String delimiter = "";
    String activeSpringProfile = null;
    String dataAccessApplicationContextConfigClassPath = null;

    for (int i = 0; i < args.length; i++) {
        if (args[i].startsWith("--")) {
            if (args[i].equals("--drop")) {
                drop = true;
            } else if (args[i].equals("--create")) {
                create = true;
            } else if (args[i].startsWith("--output=")) {
                outFile = args[i].substring(9);
            } else if (args[i].startsWith("--delimiter=")) {
                delimiter = args[i].substring(12);
            } else if (args[i].startsWith("--activeSpringProfile=")) {
                activeSpringProfile = args[i].substring(22);
            } else if (args[i].startsWith("--dataAccessApplicationContextConfigClassPath=")) {
                dataAccessApplicationContextConfigClassPath = args[i].substring(46);
            }

        }
    }

    Formatter formatter = FormatStyle.DDL.getFormatter();

    GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    if (activeSpringProfile != null) {
        context.getEnvironment().setActiveProfiles(activeSpringProfile);
    }

    context.load(dataAccessApplicationContextConfigClassPath);

    context.refresh();

    AbstractEntityManagerFactoryBean bean = context
            .getBean(AbstractEntityManagerFactoryBean.class);

    Ejb3Configuration jpaConfiguration = new Ejb3Configuration().configure(
            bean.getPersistenceUnitInfo(), bean.getJpaPropertyMap());

    SchemaExporter.export(jpaConfiguration, drop, create, outFile, delimiter, formatter);

    context.close();
}
项目:lams    文件:SchemaExport.java   
/**
 * Should we format the sql strings?
 *
 * @param format Should we format SQL strings
 * @return this
 */
public SchemaExport setFormat(boolean format) {
    this.formatter = ( format ? FormatStyle.DDL : FormatStyle.NONE ).getFormatter();
    return this;
}
项目:lams    文件:SqlStatementLogger.java   
/**
 * Log a SQL statement string.
 *
 * @param statement The SQL statement.
 */
public void logStatement(String statement) {
    // for now just assume a DML log for formatting
    logStatement( statement, FormatStyle.BASIC.getFormatter() );
}
项目:books    文件:DbOpenHelper.java   
/**
 * Format the output SQL statements.
 * 
 * @param format True to format
 */
public void setFormat(boolean format) {
    this.formatter = (format ? FormatStyle.DDL : FormatStyle.NONE).getFormatter();
}