Java Code Examples for org.hibernate.dialect.Dialect#supportsSequences()
The following examples show how to use
org.hibernate.dialect.Dialect#supportsSequences() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DatabaseMetadata.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
private void initSequences(Connection connection, Dialect dialect) throws SQLException { if ( dialect.supportsSequences() ) { String sql = dialect.getQuerySequencesString(); if (sql!=null) { Statement statement = null; ResultSet rs = null; try { statement = connection.createStatement(); rs = statement.executeQuery(sql); while ( rs.next() ) { sequences.add( rs.getString(1).toLowerCase().trim() ); } } finally { if (rs!=null) rs.close(); if (statement!=null) statement.close(); } } } }
Example 2
Source File: SequenceStyleGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { final JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); final Dialect dialect = jdbcEnvironment.getDialect(); this.identifierType = type; boolean forceTableUse = ConfigurationHelper.getBoolean( FORCE_TBL_PARAM, params, false ); final QualifiedName sequenceName = determineSequenceName( params, dialect, jdbcEnvironment, serviceRegistry ); final int initialValue = determineInitialValue( params ); int incrementSize = determineIncrementSize( params ); final String optimizationStrategy = determineOptimizationStrategy( params, incrementSize ); incrementSize = determineAdjustedIncrementSize( optimizationStrategy, incrementSize ); if ( dialect.supportsSequences() && !forceTableUse ) { if ( !dialect.supportsPooledSequences() && OptimizerFactory.isPooledOptimizer( optimizationStrategy ) ) { forceTableUse = true; LOG.forcingTableUse(); } } this.databaseStructure = buildDatabaseStructure( type, params, jdbcEnvironment, forceTableUse, sequenceName, initialValue, incrementSize ); this.optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize, ConfigurationHelper.getInt( INITIAL_PARAM, params, -1 ) ); this.databaseStructure.prepare( optimizer ); }
Example 3
Source File: SequenceStyleGenerator.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public void configure(Type type, Properties params, Dialect dialect) throws MappingException { identifierType = type; boolean forceTableUse = PropertiesHelper.getBoolean( FORCE_TBL_PARAM, params, false ); String sequenceName = PropertiesHelper.getString( SEQUENCE_PARAM, params, DEF_SEQUENCE_NAME ); if ( sequenceName.indexOf( '.' ) < 0 ) { String schemaName = params.getProperty( SCHEMA ); String catalogName = params.getProperty( CATALOG ); sequenceName = Table.qualify( catalogName, schemaName, sequenceName ); } int initialValue = PropertiesHelper.getInt( INITIAL_PARAM, params, DEFAULT_INITIAL_VALUE ); int incrementSize = PropertiesHelper.getInt( INCREMENT_PARAM, params, DEFAULT_INCREMENT_SIZE ); String valueColumnName = PropertiesHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN ); String defOptStrategy = incrementSize <= 1 ? OptimizerFactory.NONE : OptimizerFactory.POOL; String optimizationStrategy = PropertiesHelper.getString( OPT_PARAM, params, defOptStrategy ); if ( OptimizerFactory.NONE.equals( optimizationStrategy ) && incrementSize > 1 ) { log.warn( "config specified explicit optimizer of [" + OptimizerFactory.NONE + "], but [" + INCREMENT_PARAM + "=" + incrementSize + "; honoring optimizer setting" ); incrementSize = 1; } if ( dialect.supportsSequences() && !forceTableUse ) { if ( OptimizerFactory.POOL.equals( optimizationStrategy ) && !dialect.supportsPooledSequences() ) { // TODO : may even be better to fall back to a pooled table strategy here so that the db stored values remain consistent... optimizationStrategy = OptimizerFactory.HILO; } databaseStructure = new SequenceStructure( dialect, sequenceName, initialValue, incrementSize ); } else { databaseStructure = new TableStructure( dialect, sequenceName, valueColumnName, initialValue, incrementSize ); } optimizer = OptimizerFactory.buildOptimizer( optimizationStrategy, identifierType.getReturnedClass(), incrementSize ); databaseStructure.prepare( optimizer ); }