Java Code Examples for org.hibernate.boot.model.naming.Identifier#isQuoted()
The following examples show how to use
org.hibernate.boot.model.naming.Identifier#isQuoted() .
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: NormalizingIdentifierHelperImpl.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public Identifier normalizeQuoting(Identifier identifier) { log.tracef( "Normalizing identifier quoting [%s]", identifier ); if ( identifier == null ) { return null; } if ( identifier.isQuoted() ) { return identifier; } if ( globallyQuoteIdentifiers ) { log.tracef( "Forcing identifier [%s] to quoted for global quoting", identifier ); return Identifier.toIdentifier( identifier.getText(), true ); } if ( autoQuoteKeywords && isReservedWord( identifier.getText() ) ) { log.tracef( "Forcing identifier [%s] to quoted as recognized reserved word", identifier ); return Identifier.toIdentifier( identifier.getText(), true ); } return identifier; }
Example 2
Source File: InFlightMetadataCollectorImpl.java From lams with GNU General Public License v2.0 | 6 votes |
private void bindLogicalToPhysical(Identifier logicalName, String physicalName) throws DuplicateMappingException { final String existingPhysicalNameMapping = logicalToPhysical.put( logicalName, physicalName ); if ( existingPhysicalNameMapping != null ) { final boolean areSame = logicalName.isQuoted() ? physicalName.equals( existingPhysicalNameMapping ) : physicalName.equalsIgnoreCase( existingPhysicalNameMapping ); if ( !areSame ) { throw new DuplicateMappingException( String.format( Locale.ENGLISH, "Table [%s] contains logical column name [%s] referring to multiple physical " + "column names: [%s], [%s]", tableName, logicalName, existingPhysicalNameMapping, physicalName ), DuplicateMappingException.Type.COLUMN_BINDING, tableName + "." + logicalName ); } } }
Example 3
Source File: DefaultPhysicalNamingStrategy.java From micronaut-data with Apache License 2.0 | 5 votes |
private Identifier getIdentifier(Identifier name) { if (name == null) { return null; } return new Identifier( NamingStrategy.DEFAULT.mappedName(name.getText()), name.isQuoted() ); }
Example 4
Source File: NomulusNamingStrategy.java From nomulus with Apache License 2.0 | 5 votes |
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment jdbcEnvironment) { if (name.isQuoted()) { return name; } return jdbcEnvironment.getIdentifierHelper().toIdentifier(name.getText(), /* quoted= */ true); }
Example 5
Source File: NomulusNamingStrategy.java From nomulus with Apache License 2.0 | 5 votes |
@Override public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment jdbcEnvironment) { if (name.isQuoted()) { return name; } // Convert the lowerCamelCase field name into the snake_case column name return jdbcEnvironment .getIdentifierHelper() .toIdentifier( CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, name.getText()), /* quoted= */ false); }
Example 6
Source File: PrefixedNamingStrategy.java From onedev with MIT License | 4 votes |
@Override public Identifier toPhysicalTableName(Identifier name, JdbcEnvironment context) { return new Identifier(prefix+name.getText(), name.isQuoted()); }
Example 7
Source File: PrefixedNamingStrategy.java From onedev with MIT License | 4 votes |
@Override public Identifier toPhysicalSequenceName(Identifier name, JdbcEnvironment context) { return new Identifier(prefix+name.getText(), name.isQuoted()); }
Example 8
Source File: PrefixedNamingStrategy.java From onedev with MIT License | 4 votes |
@Override public Identifier toPhysicalColumnName(Identifier name, JdbcEnvironment context) { return new Identifier(prefix+name.getText(), name.isQuoted()); }
Example 9
Source File: NormalizingIdentifierHelperImpl.java From lams with GNU General Public License v2.0 | 4 votes |
private String toMetaDataText(Identifier identifier) { if ( identifier == null ) { throw new IllegalArgumentException( "Identifier cannot be null; bad usage" ); } if ( identifier instanceof DatabaseIdentifier ) { return identifier.getText(); } if ( identifier.isQuoted() ) { switch ( quotedCaseStrategy ) { case UPPER: { log.tracef( "Rendering quoted identifier [%s] in upper case for use in DatabaseMetaData", identifier ); return identifier.getText().toUpperCase( Locale.ROOT ); } case LOWER: { log.tracef( "Rendering quoted identifier [%s] in lower case for use in DatabaseMetaData", identifier ); return identifier.getText().toLowerCase( Locale.ROOT ); } default: { // default is mixed case log.tracef( "Rendering quoted identifier [%s] in mixed case for use in DatabaseMetaData", identifier ); return identifier.getText(); } } } else { switch ( unquotedCaseStrategy ) { case MIXED: { log.tracef( "Rendering unquoted identifier [%s] in mixed case for use in DatabaseMetaData", identifier ); return identifier.getText(); } case LOWER: { log.tracef( "Rendering unquoted identifier [%s] in lower case for use in DatabaseMetaData", identifier ); return identifier.getText().toLowerCase( Locale.ROOT ); } default: { // default is upper case log.tracef( "Rendering unquoted identifier [%s] in upper case for use in DatabaseMetaData", identifier ); return identifier.getText().toUpperCase( Locale.ROOT ); } } } }
Example 10
Source File: QualifiedNameParser.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Parses a textual representation of a qualified name into a NameParts * representation. Explicitly looks for the form {@code catalog.schema.name}. * * @param text The simple text representation of the qualified name. * * @return The wrapped QualifiedName */ public NameParts parse(String text, Identifier defaultCatalog, Identifier defaultSchema) { if ( text == null ) { throw new IllegalIdentifierException( "Object name to parse must be specified, but found null" ); } String catalogName = null; String schemaName = null; String name; boolean catalogWasQuoted = false; boolean schemaWasQuoted = false; boolean nameWasQuoted; // Note that we try to handle both forms of quoting, // 1) where the entire string was quoted // 2) where one or more individual parts were quoted boolean wasQuotedInEntirety = text.startsWith( "`" ) && text.endsWith( "`" ); if ( wasQuotedInEntirety ) { text = unquote( text ); } final String[] tokens = text.split( "\\." ); if ( tokens.length == 0 || tokens.length == 1 ) { // we have just a local name... name = text; } else if ( tokens.length == 2 ) { schemaName = tokens[0]; name = tokens[1]; } else if ( tokens.length == 3 ) { schemaName = tokens[0]; catalogName = tokens[1]; name = tokens[2]; } else { throw new HibernateException( "Unable to parse object name: " + text ); } nameWasQuoted = Identifier.isQuoted( name ); if ( nameWasQuoted ) { name = unquote( name ); } if ( schemaName != null ) { schemaWasQuoted = Identifier.isQuoted( schemaName ); if ( schemaWasQuoted ) { schemaName = unquote( schemaName ); } } else if ( defaultSchema != null ) { schemaName = defaultSchema.getText(); schemaWasQuoted = defaultSchema.isQuoted(); } if ( catalogName != null ) { catalogWasQuoted = Identifier.isQuoted( catalogName ); if ( catalogWasQuoted ) { catalogName = unquote( catalogName ); } } else if ( defaultCatalog != null ) { catalogName = defaultCatalog.getText(); catalogWasQuoted = defaultCatalog.isQuoted(); } return new NameParts( Identifier.toIdentifier( catalogName, wasQuotedInEntirety||catalogWasQuoted ), Identifier.toIdentifier( schemaName, wasQuotedInEntirety||schemaWasQuoted ), Identifier.toIdentifier( name, wasQuotedInEntirety||nameWasQuoted ) ); }
Example 11
Source File: QualifiedNameParser.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Parses a textual representation of a qualified name into a NameParts * representation. Explicitly looks for the form {@code catalog.schema.name}. * * @param text The simple text representation of the qualified name. * * @return The wrapped QualifiedName */ public NameParts parse(String text, Identifier defaultCatalog, Identifier defaultSchema) { if ( text == null ) { throw new IllegalIdentifierException( "Object name to parse must be specified, but found null" ); } String catalogName = null; String schemaName = null; String name; boolean catalogWasQuoted = false; boolean schemaWasQuoted = false; boolean nameWasQuoted; // Note that we try to handle both forms of quoting, // 1) where the entire string was quoted // 2) where one or more individual parts were quoted boolean wasQuotedInEntirety = text.startsWith( "`" ) && text.endsWith( "`" ); if ( wasQuotedInEntirety ) { text = unquote( text ); } final String[] tokens = text.split( "\\." ); if ( tokens.length == 0 || tokens.length == 1 ) { // we have just a local name... name = text; } else if ( tokens.length == 2 ) { schemaName = tokens[0]; name = tokens[1]; } else if ( tokens.length == 3 ) { schemaName = tokens[0]; catalogName = tokens[1]; name = tokens[2]; } else { throw new HibernateException( "Unable to parse object name: " + text ); } nameWasQuoted = Identifier.isQuoted( name ); if ( nameWasQuoted ) { name = unquote( name ); } if ( schemaName != null ) { schemaWasQuoted = Identifier.isQuoted( schemaName ); if ( schemaWasQuoted ) { schemaName = unquote( schemaName ); } } else if ( defaultSchema != null ) { schemaName = defaultSchema.getText(); schemaWasQuoted = defaultSchema.isQuoted(); } if ( catalogName != null ) { catalogWasQuoted = Identifier.isQuoted( catalogName ); if ( catalogWasQuoted ) { catalogName = unquote( catalogName ); } } else if ( defaultCatalog != null ) { catalogName = defaultCatalog.getText(); catalogWasQuoted = defaultCatalog.isQuoted(); } return new NameParts( Identifier.toIdentifier( catalogName, wasQuotedInEntirety||catalogWasQuoted ), Identifier.toIdentifier( schemaName, wasQuotedInEntirety||schemaWasQuoted ), Identifier.toIdentifier( name, wasQuotedInEntirety||nameWasQuoted ) ); }
Example 12
Source File: MyPhysicalNamingStrategy.java From bbs with GNU Affero General Public License v3.0 | 2 votes |
/** * 自定义 entity 名称与 table 名称的映射关系 * @param name * @param context * @return */ @Override public Identifier toPhysicalTableName(Identifier name,JdbcEnvironment context) { //数据库小写表名 return new Identifier(name.getText().toLowerCase(), name.isQuoted()); }