Java Code Examples for org.hibernate.engine.jdbc.env.spi.JdbcEnvironment#getDialect()
The following examples show how to use
org.hibernate.engine.jdbc.env.spi.JdbcEnvironment#getDialect() .
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: SequenceReactiveIdentifierGenerator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); Dialect dialect = jdbcEnvironment.getDialect(); qualifiedSequenceName = determineSequenceName( params, serviceRegistry ); // allow physical naming strategies a chance to kick in String renderedSequenceName = jdbcEnvironment.getQualifiedObjectNameFormatter() .format( qualifiedSequenceName, dialect ); sql = dialect.getSequenceNextValString( renderedSequenceName ); }
Example 2
Source File: TableReactiveIdentifierGenerator.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { JdbcEnvironment jdbcEnvironment = serviceRegistry.getService( JdbcEnvironment.class ); Dialect dialect = jdbcEnvironment.getDialect(); if (sequenceEmulator) { //it's a SequenceStyleGenerator backed by a table qualifiedTableName = determineSequenceName( params, serviceRegistry ); valueColumnName = determineValueColumnNameForSequenceEmulation( params, jdbcEnvironment ); segmentColumnName = null; segmentValue = null; initialValue = determineInitialValueForSequenceEmulation( params ); storeLastUsedValue = false; } else { //It's a regular TableGenerator qualifiedTableName = determineTableName( params, serviceRegistry ); segmentColumnName = determineSegmentColumnName( params, jdbcEnvironment ); valueColumnName = determineValueColumnNameForTable( params, jdbcEnvironment ); segmentValue = determineSegmentValue( params ); initialValue = determineInitialValueForTable( params ); storeLastUsedValue = serviceRegistry.getService( ConfigurationService.class ) .getSetting( Settings.TABLE_GENERATOR_STORE_LAST_USED, StandardConverters.BOOLEAN, true ); } // allow physical naming strategies a chance to kick in renderedTableName = jdbcEnvironment.getQualifiedObjectNameFormatter() .format( qualifiedTableName, dialect ); selectQuery = buildSelectQuery( dialect ); updateQuery = buildUpdateQuery( dialect ); insertQuery = buildInsertQuery( dialect ); }
Example 3
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 4
Source File: SequenceGenerator.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void registerExportables(Database database) { final Namespace namespace = database.locateNamespace( logicalQualifiedSequenceName.getCatalogName(), logicalQualifiedSequenceName.getSchemaName() ); Sequence sequence = namespace.locateSequence( logicalQualifiedSequenceName.getObjectName() ); if ( sequence != null ) { sequence.validate( 1, 1 ); } else { sequence = namespace.createSequence( logicalQualifiedSequenceName.getObjectName(), 1, 1 ); } final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); this.sequenceName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( sequence.getName(), dialect ); this.sql = jdbcEnvironment.getDialect().getSequenceNextValString( sequenceName ); }
Example 5
Source File: AbstractMultiTableBulkIdStrategyImpl.java From lams with GNU General Public License v2.0 | 5 votes |
protected String buildIdTableCreateStatement(Table idTable, JdbcServices jdbcServices, MetadataImplementor metadata) { final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); StringBuilder buffer = new StringBuilder( getIdTableSupport().getCreateIdTableCommand() ) .append( ' ' ) .append( jdbcEnvironment.getQualifiedObjectNameFormatter().format( idTable.getQualifiedTableName(), dialect ) ) .append( " (" ); Iterator itr = idTable.getColumnIterator(); while ( itr.hasNext() ) { final Column column = (Column) itr.next(); buffer.append( column.getQuotedName( dialect ) ).append( ' ' ); buffer.append( column.getSqlType( dialect, metadata ) ); if ( column.isNullable() ) { buffer.append( dialect.getNullColumnString() ); } else { buffer.append( " not null" ); } if ( itr.hasNext() ) { buffer.append( ", " ); } } buffer.append( ") " ); if ( getIdTableSupport().getCreateIdTableStatementOptions() != null ) { buffer.append( getIdTableSupport().getCreateIdTableStatementOptions() ); } return buffer.toString(); }
Example 6
Source File: AbstractMultiTableBulkIdStrategyImpl.java From lams with GNU General Public License v2.0 | 5 votes |
protected String buildIdTableDropStatement(Table idTable, JdbcServices jdbcServices) { final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); return getIdTableSupport().getDropIdTableCommand() + " " + jdbcEnvironment.getQualifiedObjectNameFormatter().format( idTable.getQualifiedTableName(), dialect ); }
Example 7
Source File: TableStructure.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void registerExportables(Database database) { final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment(); final Dialect dialect = jdbcEnvironment.getDialect(); final Namespace namespace = database.locateNamespace( logicalQualifiedTableName.getCatalogName(), logicalQualifiedTableName.getSchemaName() ); Table table = namespace.locateTable( logicalQualifiedTableName.getObjectName() ); if ( table == null ) { table = namespace.createTable( logicalQualifiedTableName.getObjectName(), false ); } this.tableNameText = jdbcEnvironment.getQualifiedObjectNameFormatter().format( table.getQualifiedTableName(), dialect ); this.valueColumnNameText = logicalValueColumnNameIdentifier.render( dialect ); this.selectQuery = "select " + valueColumnNameText + " as id_val" + " from " + dialect.appendLockHint( LockMode.PESSIMISTIC_WRITE, tableNameText ) + dialect.getForUpdateString(); this.updateQuery = "update " + tableNameText + " set " + valueColumnNameText + "= ?" + " where " + valueColumnNameText + "=?"; ExportableColumn valueColumn = new ExportableColumn( database, table, valueColumnNameText, LongType.INSTANCE ); table.addColumn( valueColumn ); table.addInitCommand( new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) ); }
Example 8
Source File: StringSequenceIdentifier.java From high-performance-java-persistence with Apache License 2.0 | 4 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(); final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class ); String globalEntityIdentifierPrefix = configurationService.getSetting( "entity.identifier.prefix", String.class, "SEQ_" ); sequencePrefix = ConfigurationHelper.getString( SEQUENCE_PREFIX, params, globalEntityIdentifierPrefix ); final String sequencePerEntitySuffix = ConfigurationHelper.getString( SequenceStyleGenerator.CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, params, SequenceStyleGenerator.DEF_SEQUENCE_SUFFIX ); boolean preferSequencePerEntity = ConfigurationHelper.getBoolean( SequenceStyleGenerator.CONFIG_PREFER_SEQUENCE_PER_ENTITY, params, false ); final String defaultSequenceName = preferSequencePerEntity ? params.getProperty(JPA_ENTITY_NAME) + sequencePerEntitySuffix : SequenceStyleGenerator.DEF_SEQUENCE_NAME; sequenceCallSyntax = dialect.getSequenceNextValString( ConfigurationHelper.getString( SequenceStyleGenerator.SEQUENCE_PARAM, params, defaultSequenceName ) ); }