column = params.getProperty( PersistentIdentifierGenerator.PK ); column = normalizer.normalizeIdentifierQuoting( column ).render( jdbcEnvironment.getDialect() ); final String schema = normalizer.toDatabaseIdentifierText( params.getProperty( PersistentIdentifierGenerator.SCHEMA ) ); final String catalog = normalizer.toDatabaseIdentifierText( params.getProperty( PersistentIdentifierGenerator.CATALOG ) ); final String tableName = normalizer.toDatabaseIdentifierText( tables[i] ); if ( tables.length > 1 ) { buf.append( "select max(" ).append( column ).append( ") as mx from " );
/** * Normalizes the quoting of identifiers. This form returns a String rather than an Identifier * to better work with the legacy code in {@link org.hibernate.mapping} * * @param identifierText The identifier to be quoting-normalized. * @return The identifier accounting for any quoting that need be applied. */ public String normalizeIdentifierQuotingAsString(String identifierText) { final Identifier identifier = normalizeIdentifierQuoting( identifierText ); if ( identifier == null ) { return null; } return identifier.render( database().getDialect() ); }
protected Database database() { if ( database == null ) { database = getBuildingContext().getMetadataCollector().getDatabase(); } return database; }
public String toDatabaseIdentifierText(String identifierText) { return database().getDialect().quote( normalizeIdentifierQuotingAsString( identifierText ) ); }
@Override @SuppressWarnings("StatementWithEmptyBody") public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException { DeprecationLogger.DEPRECATION_LOGGER.deprecatedSequenceGenerator( getClass().getName() ); identifierType = type; final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER ); logicalQualifiedSequenceName = QualifiedNameParser.INSTANCE.parse( ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" ), normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) ), normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) ) ); if ( params.containsKey( PARAMETERS ) ) { LOG.warn( "Use of 'parameters' config setting is no longer supported; " + "to specify initial-value or increment use the " + "org.hibernate.id.enhanced.SequenceStyleGenerator generator instead." ); } }
sqlType = normalizer.toDatabaseIdentifierText( columnDefinition ); name = normalizer.normalizeIdentifierQuotingAsString( defaultName ); name = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( colName ); defaultName = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( defaultName ); return new Ejb3JoinColumn( null,
/** * Determine the name of the column in which we will store the generator persistent value. * <p> * Called during {@link #configure configuration}. * * @param params The params supplied in the generator config (plus some standard useful extras). * @param dialect The dialect in effect * * @return The name of the value column */ protected String determineValueColumnName(Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER ); String name = ConfigurationHelper.getString( VALUE_COLUMN_PARAM, params, DEF_VALUE_COLUMN ); return normalizer.toDatabaseIdentifierText( name ); }
/** * Normalizes the quoting of identifiers. * <p/> * This implements the rules set forth in JPA 2 (section "2.13 Naming of Database Objects") which * states that the double-quote (") is the character which should be used to denote a <tt>quoted * identifier</tt>. Here, we handle recognizing that and converting it to the more elegant * bactick (`) approach used in Hibernate.. Additionally we account for applying what JPA2 terms * "globally quoted identifiers". * * @param identifierText The identifier to be quoting-normalized. * @return The identifier accounting for any quoting that need be applied. */ public Identifier normalizeIdentifierQuoting(String identifierText) { return database().toIdentifier( identifierText ); }
setImplicit( false ); if ( !BinderHelper.isEmptyAnnotationValue( annJoin.columnDefinition() ) ) { setSqlType( getBuildingContext().getObjectNameNormalizer().applyGlobalQuoting( annJoin.columnDefinition() ) );
@Override protected void addColumnBinding(SimpleValue value) { if ( StringHelper.isEmpty( mappedBy ) ) { // was the column explicitly quoted in the mapping/annotation // TODO: in metamodel, we need to better split global quoting and explicit quoting w/ respect to logical names boolean isLogicalColumnQuoted = StringHelper.isQuoted( getLogicalColumnName() ); final ObjectNameNormalizer nameNormalizer = getBuildingContext().getObjectNameNormalizer(); final String logicalColumnName = nameNormalizer.normalizeIdentifierQuotingAsString( getLogicalColumnName() ); final String referencedColumn = nameNormalizer.normalizeIdentifierQuotingAsString( getReferencedColumn() ); final String unquotedLogColName = StringHelper.unquote( logicalColumnName ); final String unquotedRefColumn = StringHelper.unquote( referencedColumn ); String logicalCollectionColumnName = StringHelper.isNotEmpty( unquotedLogColName ) ? unquotedLogColName : getPropertyName() + '_' + unquotedRefColumn; logicalCollectionColumnName = getBuildingContext().getMetadataCollector() .getDatabase() .getJdbcEnvironment() .getIdentifierHelper() .toIdentifier( logicalCollectionColumnName, isLogicalColumnQuoted ) .render(); getBuildingContext().getMetadataCollector().addColumnNameBinding( value.getTable(), logicalCollectionColumnName, getMappingColumn() ); } }
.getImplicitNamingStrategy(); final Identifier implicitName = normalizer.normalizeIdentifierQuoting( implicitNamingStrategy.determineBasicColumnName( new ImplicitBasicColumnNameSource() {
sqlType = normalizer.toDatabaseIdentifierText( columnDefinition ); name = normalizer.normalizeIdentifierQuotingAsString( defaultName ); name = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( colName ); defaultName = context.getObjectNameNormalizer().normalizeIdentifierQuotingAsString( defaultName ); return new Ejb3JoinColumn( null,
public String toDatabaseIdentifierText(String identifierText) { return database().getDialect().quote( normalizeIdentifierQuotingAsString( identifierText ) ); }
/** * Determine the name of the column used to indicate the segment for each * row. This column acts as the primary key. * <p> * Called during {@link #configure configuration}. * * @param params The params supplied in the generator config (plus some standard useful extras). * @param dialect The dialect in effect * * @return The name of the segment column * * @see #getSegmentColumnName() */ protected String determineSegmentColumnName(Properties params, Dialect dialect) { ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER ); String name = ConfigurationHelper.getString( SEGMENT_COLUMN_PARAM, params, DEF_SEGMENT_COLUMN ); return normalizer.toDatabaseIdentifierText( name ); }
/** * Intended only for use in handling quoting requirements for {@code column-definition} * as defined by {@link javax.persistence.Column#columnDefinition()}, * {@link javax.persistence.JoinColumn#columnDefinition}, etc. This method should not * be called in any other scenario. * * @param text The specified column definition * * @return The name with global quoting applied */ public String applyGlobalQuoting(String text) { return database().getJdbcEnvironment().getIdentifierHelper().applyGlobalQuoting( text ) .render( database().getDialect() ); }
sqlType = normalizer.applyGlobalQuoting( col.columnDefinition() );
final AttributePath attributePath = AttributePath.parse( propertyName ); Identifier implicitName = normalizer.normalizeIdentifierQuoting( implicitNamingStrategy.determineBasicColumnName( new ImplicitBasicColumnNameSource() { mappingColumn.setName( normalizer.toDatabaseIdentifierText( columnName ) );
@Override @SuppressWarnings("StatementWithEmptyBody") public void configure(JavaTypeDescriptor javaTypeDescriptor, Properties params, ServiceRegistry serviceRegistry) throws MappingException { DeprecationLogger.DEPRECATION_LOGGER.deprecatedSequenceGenerator( getClass().getName() ); identifierType = javaTypeDescriptor; final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER ); logicalQualifiedSequenceName = QualifiedNameParser.INSTANCE.parse( ConfigurationHelper.getString( SEQUENCE, params, "hibernate_sequence" ), normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) ), normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) ) ); if ( params.containsKey( PARAMETERS ) ) { LOG.warn( "Use of 'parameters' config setting is no longer supported; " + "to specify initial-value or increment use the " + "org.hibernate.id.enhanced.SequenceStyleGenerator generator instead." ); } }
/** * Normalizes the quoting of identifiers. This form returns a String rather than an Identifier * to better work with the legacy code in {@link org.hibernate.mapping} * * @param identifierText The identifier to be quoting-normalized. * @return The identifier accounting for any quoting that need be applied. */ public String normalizeIdentifierQuotingAsString(String identifierText) { final Identifier identifier = normalizeIdentifierQuoting( identifierText ); if ( identifier == null ) { return null; } return identifier.render( database().getDialect() ); }
/** * Determine the logical name give a (potentially {@code null}/empty) explicit name. * * @param explicitName The explicit, user-supplied name * @param namingStrategyHelper The naming strategy helper. * * @return The logical name */ public Identifier determineLogicalName(String explicitName, NamingStrategyHelper namingStrategyHelper) { Identifier logicalName; if ( StringHelper.isEmpty( explicitName ) ) { logicalName = namingStrategyHelper.determineImplicitName( getBuildingContext() ); } else { logicalName = namingStrategyHelper.handleExplicitName( explicitName, getBuildingContext() ); } logicalName = getBuildingContext().getMetadataCollector() .getDatabase() .getJdbcEnvironment() .getIdentifierHelper() .normalizeQuoting( logicalName ); return logicalName; }