org.hibernate.engine.jdbc.env.spi.IdentifierHelper Java Examples
The following examples show how to use
org.hibernate.engine.jdbc.env.spi.IdentifierHelper.
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: QuarkusPostgreSQL10Dialect.java From quarkus with Apache License 2.0 | 5 votes |
@Override public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { // PostgreSQL considers unquoted identifiers lowercase // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS builder.setUnquotedCaseStrategy(IdentifierCaseStrategy.LOWER); // then delegate to the database metadata driver identifier casing selection // which can override these settings. return super.buildIdentifierHelper(builder, dbMetaData); }
Example #2
Source File: QuarkusH2Dialect.java From quarkus with Apache License 2.0 | 5 votes |
@Override public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { // H2 by default consider identifiers as upper case // unless DATABASE_TO_UPPER=false but that's not the default // and Thomas Mueller says it's normal ANSI-SQL SQL-92 behavior // http://h2-database.66688.n3.nabble.com/Case-of-column-name-td3485519.html // http://www.h2database.com/html/grammar.html#name // DATABASE_TO_LOWER=TRUE will come with H2's next version as of Feb 2019 but only for PostgreSQL compat builder.setUnquotedCaseStrategy(IdentifierCaseStrategy.UPPER); // then delegate to the database metadata driver identifier casing selection // which can override these settings. return super.buildIdentifierHelper(builder, dbMetaData); }
Example #3
Source File: QuarkusPostgreSQL95Dialect.java From quarkus with Apache License 2.0 | 5 votes |
@Override public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { // PostgreSQL considers unquoted identifiers lowercase // https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS builder.setUnquotedCaseStrategy(IdentifierCaseStrategy.LOWER); // then delegate to the database metadata driver identifier casing selection // which can override these settings. return super.buildIdentifierHelper(builder, dbMetaData); }
Example #4
Source File: TableInformationImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public TableInformationImpl( InformationExtractor extractor, IdentifierHelper identifierHelper, QualifiedTableName tableName, boolean physicalTable, String comment ) { this.extractor = extractor; this.identifierHelper = identifierHelper; this.tableName = tableName; this.physicalTable = physicalTable; this.comment = comment; }
Example #5
Source File: TestingRegistryRule.java From hibernate-reactive with GNU Lesser General Public License v2.1 | 4 votes |
@Override @SuppressWarnings("unchecked") public <R extends Service> R getService(Class<R> serviceRole) { if ( serviceRole == VertxInstance.class ) { return (R) vertxService; } else if ( serviceRole == JdbcEnvironment.class ) { return (R) new JdbcEnvironment() { @Override public Dialect getDialect() { return new MySQL8Dialect(); } @Override public ExtractedDatabaseMetaData getExtractedDatabaseMetaData() { return null; } @Override public Identifier getCurrentCatalog() { return null; } @Override public Identifier getCurrentSchema() { return null; } @Override public QualifiedObjectNameFormatter getQualifiedObjectNameFormatter() { return null; } @Override public IdentifierHelper getIdentifierHelper() { return null; } @Override public NameQualifierSupport getNameQualifierSupport() { return null; } @Override public SqlExceptionHelper getSqlExceptionHelper() { return null; } @Override public LobCreatorBuilder getLobCreatorBuilder() { return null; } @Override public TypeInfo getTypeInfoForJdbcCode(int jdbcTypeCode) { return null; } }; } else { throw new IllegalArgumentException( "This is a mock service - need to explicitly handle any service we might need during testing" ); } }
Example #6
Source File: NameSpaceTablesInformation.java From lams with GNU General Public License v2.0 | 4 votes |
public NameSpaceTablesInformation(IdentifierHelper identifierHelper) { this.identifierHelper = identifierHelper; }
Example #7
Source File: InformationExtractorJdbcDatabaseMetaDataImpl.java From lams with GNU General Public License v2.0 | 4 votes |
protected IdentifierHelper identifierHelper() { return extractionContext.getJdbcEnvironment().getIdentifierHelper(); }
Example #8
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 #9
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 #10
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 #11
Source File: JdbcEnvironmentImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public IdentifierHelper getIdentifierHelper() { return identifierHelper; }
Example #12
Source File: DelegatingDialect.java From keycloak with Apache License 2.0 | 4 votes |
@Override public IdentifierHelper buildIdentifierHelper( IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData) throws SQLException { return getInstance().buildIdentifierHelper(builder, dbMetaData); }
Example #13
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 #14
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(); }