Java Code Examples for org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder#build()
The following examples show how to use
org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder#build() .
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: JdbcEnvironmentImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Constructor form used when the JDBC {@link java.sql.DatabaseMetaData} is not available. * * @param serviceRegistry The service registry * @param dialect The resolved dialect. */ public JdbcEnvironmentImpl(ServiceRegistryImplementor serviceRegistry, Dialect dialect) { this.dialect = dialect; final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); NameQualifierSupport nameQualifierSupport = dialect.getNameQualifierSupport(); if ( nameQualifierSupport == null ) { // assume both catalogs and schemas are supported nameQualifierSupport = NameQualifierSupport.BOTH; } this.nameQualifierSupport = nameQualifierSupport; this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService, dialect ) ); final IdentifierHelperBuilder identifierHelperBuilder = IdentifierHelperBuilder.from( this ); identifierHelperBuilder.setGloballyQuoteIdentifiers( globalQuoting( cfgService ) ); identifierHelperBuilder.setSkipGlobalQuotingForColumnDefinitions( globalQuotingSkippedForColumnDefinitions( cfgService ) ); identifierHelperBuilder.setAutoQuoteKeywords( autoKeywordQuoting( cfgService ) ); identifierHelperBuilder.setNameQualifierSupport( nameQualifierSupport ); IdentifierHelper identifierHelper = null; ExtractedDatabaseMetaDataImpl.Builder dbMetaDataBuilder = new ExtractedDatabaseMetaDataImpl.Builder( this ); try { identifierHelper = dialect.buildIdentifierHelper( identifierHelperBuilder, null ); dbMetaDataBuilder.setSupportsNamedParameters( dialect.supportsNamedParameters( null ) ); } catch (SQLException sqle) { // should never ever happen log.debug( "There was a problem accessing DatabaseMetaData in building the JdbcEnvironment", sqle ); } if ( identifierHelper == null ) { identifierHelper = identifierHelperBuilder.build(); } this.identifierHelper = identifierHelper; this.extractedMetaDataSupport = dbMetaDataBuilder.build(); this.currentCatalog = identifierHelper.toIdentifier( cfgService.getSetting( AvailableSettings.DEFAULT_CATALOG, StandardConverters.STRING ) ); this.currentSchema = Identifier.toIdentifier( cfgService.getSetting( AvailableSettings.DEFAULT_SCHEMA, StandardConverters.STRING ) ); this.qualifiedObjectNameFormatter = new QualifiedObjectNameFormatterStandardImpl( nameQualifierSupport ); this.lobCreatorBuilder = LobCreatorBuilderImpl.makeLobCreatorBuilder(); }
Example 2
Source File: JdbcEnvironmentImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Constructor form used from testing * * @param dialect The dialect */ public JdbcEnvironmentImpl(DatabaseMetaData databaseMetaData, Dialect dialect) throws SQLException { this.dialect = dialect; this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, false ); this.extractedMetaDataSupport = new ExtractedDatabaseMetaDataImpl.Builder( this ) .apply( databaseMetaData ) .setSupportsNamedParameters( databaseMetaData.supportsNamedParameters() ) .build(); NameQualifierSupport nameQualifierSupport = dialect.getNameQualifierSupport(); if ( nameQualifierSupport == null ) { nameQualifierSupport = determineNameQualifierSupport( databaseMetaData ); } this.nameQualifierSupport = nameQualifierSupport; final IdentifierHelperBuilder identifierHelperBuilder = IdentifierHelperBuilder.from( this ); identifierHelperBuilder.setNameQualifierSupport( nameQualifierSupport ); IdentifierHelper identifierHelper = null; try { identifierHelper = dialect.buildIdentifierHelper( identifierHelperBuilder, databaseMetaData ); } catch (SQLException sqle) { // should never ever happen log.debug( "There was a problem accessing DatabaseMetaData in building the JdbcEnvironment", sqle ); } if ( identifierHelper == null ) { identifierHelper = identifierHelperBuilder.build(); } this.identifierHelper = identifierHelper; this.currentCatalog = null; this.currentSchema = null; this.qualifiedObjectNameFormatter = new QualifiedObjectNameFormatterStandardImpl( nameQualifierSupport, databaseMetaData ); this.lobCreatorBuilder = LobCreatorBuilderImpl.makeLobCreatorBuilder(); }
Example 3
Source File: JdbcEnvironmentImpl.java From lams with GNU General Public License v2.0 | 4 votes |
/** * The main constructor form. Builds a JdbcEnvironment using the available DatabaseMetaData * * @param serviceRegistry The service registry * @param dialect The resolved dialect * @param databaseMetaData The available DatabaseMetaData * * @throws SQLException */ public JdbcEnvironmentImpl( ServiceRegistryImplementor serviceRegistry, Dialect dialect, DatabaseMetaData databaseMetaData) throws SQLException { this.dialect = dialect; final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class ); this.sqlExceptionHelper = buildSqlExceptionHelper( dialect, logWarnings( cfgService, dialect ) ); this.extractedMetaDataSupport = new ExtractedDatabaseMetaDataImpl.Builder( this ) .apply( databaseMetaData ) .setConnectionSchemaName( determineCurrentSchemaName( databaseMetaData, serviceRegistry, dialect ) ) .setSupportsNamedParameters(dialect.supportsNamedParameters(databaseMetaData)) .build(); NameQualifierSupport nameQualifierSupport = dialect.getNameQualifierSupport(); if ( nameQualifierSupport == null ) { nameQualifierSupport = determineNameQualifierSupport( databaseMetaData ); } this.nameQualifierSupport = nameQualifierSupport; final IdentifierHelperBuilder identifierHelperBuilder = IdentifierHelperBuilder.from( this ); identifierHelperBuilder.setGloballyQuoteIdentifiers( globalQuoting( cfgService ) ); identifierHelperBuilder.setSkipGlobalQuotingForColumnDefinitions( globalQuotingSkippedForColumnDefinitions( cfgService ) ); identifierHelperBuilder.setAutoQuoteKeywords( autoKeywordQuoting( cfgService ) ); identifierHelperBuilder.setNameQualifierSupport( nameQualifierSupport ); IdentifierHelper identifierHelper = null; try { identifierHelper = dialect.buildIdentifierHelper( identifierHelperBuilder, databaseMetaData ); } catch (SQLException sqle) { // should never ever happen log.debug( "There was a problem accessing DatabaseMetaData in building the JdbcEnvironment", sqle ); } if ( identifierHelper == null ) { identifierHelper = identifierHelperBuilder.build(); } this.identifierHelper = identifierHelper; // and that current-catalog and current-schema happen after it this.currentCatalog = identifierHelper.toIdentifier( extractedMetaDataSupport.getConnectionCatalogName() ); this.currentSchema = identifierHelper.toIdentifier( extractedMetaDataSupport.getConnectionSchemaName() ); this.qualifiedObjectNameFormatter = new QualifiedObjectNameFormatterStandardImpl( nameQualifierSupport, databaseMetaData ); this.typeInfoSet.addAll( TypeInfo.extractTypeInfo( databaseMetaData ) ); this.lobCreatorBuilder = LobCreatorBuilderImpl.makeLobCreatorBuilder( cfgService.getSettings(), databaseMetaData.getConnection() ); }
Example 4
Source File: DerbyDialect.java From lams with GNU General Public License v2.0 | 3 votes |
@Override public IdentifierHelper buildIdentifierHelper( IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { builder.applyIdentifierCasing( dbMetaData ); builder.applyReservedWords( dbMetaData ); builder.applyReservedWords( getKeywords() ); builder.setNameQualifierSupport( getNameQualifierSupport() ); return builder.build(); }
Example 5
Source File: Dialect.java From lams with GNU General Public License v2.0 | 3 votes |
/** * Build the IdentifierHelper indicated by this Dialect for handling identifier conversions. * Returning {@code null} is allowed and indicates that Hibernate should fallback to building a * "standard" helper. In the fallback path, any changes made to the IdentifierHelperBuilder * during this call will still be incorporated into the built IdentifierHelper. * <p/> * The incoming builder will have the following set:<ul> * <li>{@link IdentifierHelperBuilder#isGloballyQuoteIdentifiers()}</li> * <li>{@link IdentifierHelperBuilder#getUnquotedCaseStrategy()} - initialized to UPPER</li> * <li>{@link IdentifierHelperBuilder#getQuotedCaseStrategy()} - initialized to MIXED</li> * </ul> * <p/> * By default Hibernate will do the following:<ul> * <li>Call {@link IdentifierHelperBuilder#applyIdentifierCasing(DatabaseMetaData)} * <li>Call {@link IdentifierHelperBuilder#applyReservedWords(DatabaseMetaData)} * <li>Applies {@link AnsiSqlKeywords#sql2003()} as reserved words</li> * <li>Applies the {#link #sqlKeywords} collected here as reserved words</li> * <li>Applies the Dialect's NameQualifierSupport, if it defines one</li> * </ul> * * @param builder A semi-configured IdentifierHelper builder. * @param dbMetaData Access to the metadata returned from the driver if needed and if available. WARNING: may be {@code null} * * @return The IdentifierHelper instance to use, or {@code null} to indicate Hibernate should use its fallback path * * @throws SQLException Accessing the DatabaseMetaData can throw it. Just re-throw and Hibernate will handle. * * @see #getNameQualifierSupport() */ public IdentifierHelper buildIdentifierHelper( IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { builder.applyIdentifierCasing( dbMetaData ); builder.applyReservedWords( dbMetaData ); builder.applyReservedWords( AnsiSqlKeywords.INSTANCE.sql2003() ); builder.applyReservedWords( sqlKeywords ); builder.setNameQualifierSupport( getNameQualifierSupport() ); return builder.build(); }