Java Code Examples for org.hibernate.boot.model.naming.Identifier#render()

The following examples show how to use org.hibernate.boot.model.naming.Identifier#render() . 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 Project: lams   File: Ejb3Column.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected void addColumnBinding(SimpleValue value) {
	final String logicalColumnName;
	if ( StringHelper.isNotEmpty( this.logicalColumnName ) ) {
		logicalColumnName = this.logicalColumnName;
	}
	else {
		final ObjectNameNormalizer normalizer = context.getObjectNameNormalizer();
		final Database database = context.getMetadataCollector().getDatabase();
		final ImplicitNamingStrategy implicitNamingStrategy = context.getBuildingOptions()
				.getImplicitNamingStrategy();

		final Identifier implicitName = normalizer.normalizeIdentifierQuoting(
				implicitNamingStrategy.determineBasicColumnName(
						new ImplicitBasicColumnNameSource() {
							@Override
							public AttributePath getAttributePath() {
								return AttributePath.parse( propertyName );
							}

							@Override
							public boolean isCollectionElement() {
								return false;
							}

							@Override
							public MetadataBuildingContext getBuildingContext() {
								return context;
							}
						}
				)
		);
		logicalColumnName = implicitName.render( database.getDialect() );
	}
	context.getMetadataCollector().addColumnNameBinding( value.getTable(), logicalColumnName, getMappingColumn() );
}
 
Example 2
private static String render(Identifier identifier, Dialect dialect) {
	if ( identifier == null ) {
		return null;
	}

	return identifier.render( dialect );
}
 
Example 3
@Override
public String getLogicalTableName(Table ownerTable) {
	final Identifier logicalName = physicalToLogicalTableNameMap.get( ownerTable.getNameIdentifier() );
	if ( logicalName == null ) {
		throw new MappingException( "Unable to find physical table: " + ownerTable.getName() );
	}
	return logicalName.render();
}
 
Example 4
@Override
public String getPhysicalColumnName(Table table, Identifier logicalName) throws MappingException {
	if ( logicalName == null ) {
		throw new MappingException( "Logical column name cannot be null" );
	}

	Table currentTable = table;
	String physicalName = null;

	while ( currentTable != null ) {
		final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable );
		if ( binding != null ) {
			physicalName = binding.logicalToPhysical.get( logicalName );
			if ( physicalName != null ) {
				break;
			}
		}

		if ( DenormalizedTable.class.isInstance( currentTable ) ) {
			currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable();
		}
		else {
			currentTable = null;
		}
	}

	if ( physicalName == null ) {
		throw new MappingException(
				"Unable to find column with logical name " + logicalName.render() + " in table " + table.getName()
		);
	}
	return physicalName;
}
 
Example 5
@Override
public String getLogicalColumnName(Table table, Identifier physicalName) throws MappingException {
	final String physicalNameString = physicalName.render( getDatabase().getJdbcEnvironment().getDialect() );
	Identifier logicalName = null;

	Table currentTable = table;
	while ( currentTable != null ) {
		final TableColumnNameBinding binding = columnNameBindingByTableMap.get( currentTable );

		if ( binding != null ) {
			logicalName = binding.physicalToLogical.get( physicalNameString );
			if ( logicalName != null ) {
				break;
			}
		}

		if ( DenormalizedTable.class.isInstance( currentTable ) ) {
			currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable();
		}
		else {
			currentTable = null;
		}
	}

	if ( logicalName == null ) {
		throw new MappingException(
				"Unable to find column with physical name " + physicalNameString + " in table " + table.getName()
		);
	}
	return logicalName.render();
}
 
Example 6
Source Project: lams   File: TableBinder.java    License: GNU General Public License v2.0 4 votes vote down vote up
private static String extract(Identifier identifier) {
	if ( identifier == null ) {
		return null;
	}
	return identifier.render();
}
 
Example 7
Source Project: lams   File: Settings.java    License: GNU General Public License v2.0 4 votes vote down vote up
private static String extractName(Identifier identifier) {
	return identifier == null ? null : identifier.render();
}
 
Example 8
Source Project: lams   File: Table.java    License: GNU General Public License v2.0 4 votes vote down vote up
private String render(Identifier identifier) {
	return identifier == null ? null : identifier.render();
}
 
Example 9
private TableInformation processTableResults(
		Identifier catalog,
		Identifier schema,
		Identifier tableName,
		ResultSet resultSet) throws SQLException {
	try {
		boolean found = false;
		TableInformation tableInformation = null;
		while ( resultSet.next() ) {
			if ( tableName.equals( Identifier.toIdentifier( resultSet.getString( "TABLE_NAME" ),
															tableName.isQuoted() ) ) ) {
				if ( found ) {
					log.multipleTablesFound( tableName.render() );
					final String catalogName = catalog == null ? "" : catalog.render();
					final String schemaName = schema == null ? "" : schema.render();
					throw new SchemaExtractionException(
							String.format(
									Locale.ENGLISH,
									"More than one table found in namespace (%s, %s) : %s",
									catalogName,
									schemaName,
									tableName.render()
							)
					);
				}
				else {
					found = true;
					tableInformation = extractTableInformation( resultSet );
					addColumns( tableInformation );
				}
			}
		}
		if ( !found ) {
			log.tableNotFound( tableName.render() );
		}
		return tableInformation;
	}
	finally {
		try {
			resultSet.close();
		}
		catch (SQLException ignore) {
		}
	}
}
 
Example 10
private String getDefaultCatalogName(Database database, Dialect dialect) {
	final Identifier identifier = database.getDefaultNamespace().getPhysicalName().getCatalog();
	return identifier == null ? null : identifier.render( dialect );
}
 
Example 11
private String getDefaultSchemaName(Database database, Dialect dialect) {
	final Identifier identifier = database.getDefaultNamespace().getPhysicalName().getSchema();
	return identifier == null ? null : identifier.render( dialect );
}
 
Example 12
@Override
public String getPhysicalTableName(Identifier logicalName) {
	final Identifier physicalName = logicalToPhysicalTableNameMap.get( logicalName );
	return physicalName == null ? null : physicalName.render();
}
 
Example 13
private String extractName(Identifier identifier, Dialect dialect) {
	if ( identifier == null ) {
		return null;
	}
	return identifier.render( dialect );
}