private static Dialect determineDialect() { try { return Dialect.getDialect(); } catch (Exception e) { return new Dialect() { }; } }
public boolean isMatch(Dialect dialect) { return dialect.supportsSequences(); } }
public SequenceInformationExtractor getSequenceInformationExtractor() { if ( getQuerySequencesString() == null ) { return SequenceInformationExtractorNoOpImpl.INSTANCE; } else { return SequenceInformationExtractorLegacyImpl.INSTANCE; } }
@Override public boolean isMatch(Dialect dialect) { return '\"' == dialect.openQuote() && '\"' == dialect.closeQuote(); } }
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { return new String[] { dialect.getCreateTableString() + ' ' + tableName + " ( " + segmentColumnName + ' ' + dialect.getTypeName( Types.VARCHAR, keySize, 0, 0 ) + ", " + valueColumnName + ' ' + dialect.getTypeName( Types.INTEGER ) + " )" + dialect.getTableTypeString() }; }
@Override public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { return new String[] { dialect.getCreateTableString() + " " + tableNameText + " ( " + valueColumnNameText + " " + dialect.getTypeName( Types.BIGINT ) + " )", "insert into " + tableNameText + " values ( " + initialValue + " )" }; }
table.setPrimaryKey( new PrimaryKey( table ) ); segmentColumnName, StringType.INSTANCE, database.getDialect().getTypeName( Types.VARCHAR, keySize, 0, 0 ) ); pkColumn.setNullable( false ); table.addColumn( pkColumn ); table.getPrimaryKey().addColumn( pkColumn ); valueColumnName + " from " + jdbcEnvironment.getDialect().appendLockHint( LockMode.PESSIMISTIC_WRITE, tableName ) + " where " + segmentColumnName + " = '" + segmentName + "'" + jdbcEnvironment.getDialect().getForUpdateString();
public String getSqlType(Dialect dialect, Mapping mapping) throws HibernateException { if ( sqlType == null ) { sqlType = dialect.getTypeName( getSqlTypeCode( mapping ), getLength(), getPrecision(), getScale() ); } return sqlType; }
segmentColumnName, StringType.INSTANCE, dialect.getTypeName( Types.VARCHAR, segmentValueLength, 0, 0 ) ); segmentColumn.setNullable( false ); table.addColumn( segmentColumn ); table.setPrimaryKey( new PrimaryKey( table ) ); table.getPrimaryKey().addColumn( segmentColumn );
private boolean doesDialectSupportDropTableIfExist() { return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect() .supportsIfExistsBeforeTableName(); }
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment(); final String tableName = jdbcEnvironment.getQualifiedObjectNameFormatter().format( index.getTable().getQualifiedTableName(), jdbcEnvironment.getDialect() ); if ( getDialect().qualifyIndexName() ) { indexNameForCreation = jdbcEnvironment.getQualifiedObjectNameFormatter().format( new QualifiedNameImpl( index.getTable().getQualifiedTableName().getCatalogName(), index.getTable().getQualifiedTableName().getSchemaName(), jdbcEnvironment.getIdentifierHelper().toIdentifier( index.getName() ) ), colBuf.append( ", " ); colBuf.append( ( column.getQuotedName( jdbcEnvironment.getDialect() )) );
table.getQualifiedTableName(), dialect ); " from " + dialect.appendLockHint( LockMode.PESSIMISTIC_WRITE, tableNameText ) + dialect.getForUpdateString(); LongType.INSTANCE ); table.addColumn( valueColumn ); table.addInitCommand( new InitCommand( "insert into " + tableNameText + " values ( " + initialValue + " )" ) );
public void configure(Type type, Properties params, Dialect dialect) { tableName = PropertiesHelper.getString(TABLE, params, DEFAULT_TABLE_NAME); columnName = PropertiesHelper.getString(COLUMN, params, DEFAULT_COLUMN_NAME); String schemaName = params.getProperty(SCHEMA); String catalogName = params.getProperty(CATALOG); if ( tableName.indexOf( '.' )<0 ) { tableName = Table.qualify( catalogName, schemaName, tableName ); } query = "select " + columnName + " from " + dialect.appendLockHint(LockMode.UPGRADE, tableName) + dialect.getForUpdateString(); update = "update " + tableName + " set " + columnName + " = ? where " + columnName + " = ?"; }
@Override @SuppressWarnings( {"deprecation"}) public String[] sqlCreateStrings(Dialect dialect) throws HibernateException { return dialect.getCreateSequenceStrings( sequenceName, 1, 1 ); }
@Override public void registerExportables(Database database) { buildSequence( database ); this.sql = database.getJdbcEnvironment().getDialect().getSequenceNextValString( sequenceName ); }
/** * Get the string to append to SELECT statements to acquire READ locks * for this dialect. Location of the of the returned string is treated * the same as getForUpdateString. * * @param timeout in milliseconds, -1 for indefinite wait and 0 for no wait. * @return The appropriate <tt>LOCK</tt> clause string. */ public String getReadLockString(int timeout) { return getForUpdateString(); }
@Override public void configure(Type type, Properties params, Dialect dialect) throws MappingException { ObjectNameNormalizer normalizer = ( ObjectNameNormalizer ) params.get( IDENTIFIER_NORMALIZER ); sequenceName = normalizer.normalizeIdentifierQuoting( ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" ) ); parameters = params.getProperty( PARAMETERS ); if ( sequenceName.indexOf( '.' ) < 0 ) { final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) ); final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) ); sequenceName = Table.qualify( dialect.quote( catalogName ), dialect.quote( schemaName ), dialect.quote( sequenceName ) ); } else { // if already qualified there is not much we can do in a portable manner so we pass it // through and assume the user has set up the name correctly. } this.identifierType = type; sql = dialect.getSequenceNextValString( sequenceName ); }
.append( dialect.appendLockHint( lockOptions, tableName ) ); buf = new StringBuilder(dialect.applyLocksToSql( buf.toString(), lockOptions, null ) ); return dialect.transformSelectString( buf.toString() );
@Override public void configure(Configuration cfg) { super.configure( cfg ); if ( !useAntlrParser ) { cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() ); try { String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true ); // if this call succeeds, then the dialect is saying to represent true/false as int values... Integer.parseInt( dialectTrueRepresentation ); String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS ); if ( subs == null ) { subs = ""; } if ( StringHelper.isEmpty( subs ) ) { subs = "true=1, false=0"; } else { subs += ", true=1, false=0"; } cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs ); // cfg.setNamingStrategy( DefaultNamingStrategy.INSTANCE ); } catch( NumberFormatException nfe ) { // the Integer#parseInt call failed... } } cfg.setProperty( AvailableSettings.JDBC_TYLE_PARAMS_ZERO_BASE, "true" ); }
/** * Get an instance of the dialect specified by the given properties or by * the current <tt>System</tt> properties. * * @param props The properties to use for finding the dialect class to use. * @return The specified Dialect * @throws HibernateException If no dialect was specified, or if it could not be instantiated. */ public static Dialect getDialect(Properties props) throws HibernateException { final String dialectName = props.getProperty( Environment.DIALECT ); if ( dialectName == null ) { return getDialect(); } return instantiateDialect( dialectName ); }