| protected final Map | columnNameBindingPerTable | binding table between the logical column name and the name out of the naming strategy
for each table.
According that when the column name is not set, the property name is considered as such
This means that while theorically possible through the naming strategy contract, it is
forbidden to have 2 real columns having the same logical name
| protected final Map | tableNameBinding | binding between logical table name and physical one (ie after the naming strategy has been applied)
|
| Constructor: |
Mappings(Map classes,
Map collections,
Map tables,
Map queries,
Map sqlqueries,
Map sqlResultSetMappings,
Map imports,
List secondPasses,
List propertyReferences,
NamingStrategy namingStrategy,
Map typeDefs,
Map filterDefinitions,
Map extendsQueue,
List auxiliaryDatabaseObjects,
Map tableNamebinding,
Map columnNameBindingPerTable) {
// final List extendsQueue,
this.classes = classes;
this.collections = collections;
this.queries = queries;
this.sqlqueries = sqlqueries;
this.resultSetMappings = sqlResultSetMappings;
this.tables = tables;
this.imports = imports;
this.secondPasses = secondPasses;
this.propertyReferences = propertyReferences;
this.namingStrategy = namingStrategy;
this.typeDefs = typeDefs;
this.filterDefinitions = filterDefinitions;
this.extendsQueue = extendsQueue;
this.auxiliaryDatabaseObjects = auxiliaryDatabaseObjects;
this.tableNameBinding = tableNamebinding;
this.columnNameBindingPerTable = columnNameBindingPerTable;
}
|
| Method from org.hibernate.cfg.Mappings Summary: |
|---|
|
addAuxiliaryDatabaseObject, addClass, addCollection, addColumnBinding, addDenormalizedTable, addFilterDefinition, addImport, addPropertyReference, addQuery, addResultSetMapping, addSQLQuery, addSecondPass, addSecondPass, addTable, addTableBinding, addToExtendsQueue, addTypeDef, addUniquePropertyReference, getCatalogName, getClass, getCollection, getDefaultAccess, getDefaultCascade, getDefaultPackage, getFilterDefinition, getFilterDefinitions, getLogicalColumnName, getLogicalTableName, getNamingStrategy, getPhysicalColumnName, getQuery, getResultSetMapping, getSchemaName, getTable, getTypeDef, isAutoImport, isDefaultLazy, iterateCollections, iterateTables, locatePersistentClassByEntityName, setAutoImport, setCatalogName, setDefaultAccess, setDefaultCascade, setDefaultLazy, setDefaultPackage, setSchemaName |
| Method from org.hibernate.cfg.Mappings Detail: |
public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) {
auxiliaryDatabaseObjects.add( auxiliaryDatabaseObject );
}
| public void addClass(PersistentClass persistentClass) throws MappingException {
Object old = classes.put( persistentClass.getEntityName(), persistentClass );
if ( old!=null ) {
throw new DuplicateMappingException( "class/entity", persistentClass.getEntityName() );
}
}
| public void addCollection(Collection collection) throws MappingException {
Object old = collections.put( collection.getRole(), collection );
if ( old!=null ) {
throw new DuplicateMappingException( "collection role", collection.getRole() );
}
}
| public void addColumnBinding(String logicalName,
Column finalColumn,
Table table) {
ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(table);
if (binding == null) {
binding = new ColumnNames();
columnNameBindingPerTable.put(table, binding);
}
String oldFinalName = (String) binding.logicalToPhysical.put(
logicalName.toLowerCase(),
finalColumn.getQuotedName()
);
if ( oldFinalName != null &&
! ( finalColumn.isQuoted() ?
oldFinalName.equals( finalColumn.getQuotedName() ) :
oldFinalName.equalsIgnoreCase( finalColumn.getQuotedName() ) ) ) {
//TODO possibly relax that
throw new MappingException("Same logical column name referenced by different physical ones: "
+ table.getName() + "." + logicalName + " = > '" + oldFinalName + "' and '" + finalColumn.getQuotedName() + "'" );
}
String oldLogicalName = (String) binding.physicalToLogical.put(
finalColumn.getQuotedName(),
logicalName
);
if ( oldLogicalName != null && ! oldLogicalName.equals( logicalName ) ) {
//TODO possibly relax that
throw new MappingException("Same physical column represented by different logical column names: "
+ table.getName() + "." + finalColumn.getQuotedName() + " = > '" + oldLogicalName + "' and '" + logicalName + "'");
}
}
| public Table addDenormalizedTable(String schema,
String catalog,
String name,
boolean isAbstract,
String subselect,
Table includedTable) throws MappingException {
String key = subselect==null ?
Table.qualify(catalog, schema, name) :
subselect;
if ( tables.containsKey(key) ) {
throw new DuplicateMappingException("table", name);
}
Table table = new DenormalizedTable(includedTable);
table.setAbstract(isAbstract);
table.setName(name);
table.setSchema(schema);
table.setCatalog(catalog);
table.setSubselect(subselect);
tables.put(key, table);
return table;
}
| public void addFilterDefinition(FilterDefinition definition) {
filterDefinitions.put( definition.getFilterName(), definition );
}
| public void addImport(String className,
String rename) throws MappingException {
String existing = (String) imports.put(rename, className);
if ( existing!=null ) {
if ( existing.equals(className) ) {
log.info( "duplicate import: " + className + "- >" + rename );
}
else {
throw new DuplicateMappingException(
"duplicate import: " + rename +
" refers to both " + className +
" and " + existing +
" (try using auto-import=\"false\")",
"import",
rename
);
}
}
}
| void addPropertyReference(String referencedClass,
String propertyName) {
PropertyReference upr = new PropertyReference();
upr.referencedClass = referencedClass;
upr.propertyName = propertyName;
propertyReferences.add(upr);
}
| public void addQuery(String name,
NamedQueryDefinition query) throws MappingException {
checkQueryExist(name);
queries.put( name.intern(), query );
}
| public void addResultSetMapping(ResultSetMappingDefinition sqlResultSetMapping) {
final String name = sqlResultSetMapping.getName();
if ( resultSetMappings.containsKey(name) ) {
throw new DuplicateMappingException("resultSet", name);
}
resultSetMappings.put(name, sqlResultSetMapping);
}
| public void addSQLQuery(String name,
NamedSQLQueryDefinition query) throws MappingException {
checkQueryExist(name);
sqlqueries.put( name.intern(), query );
}
| public void addSecondPass(SecondPass sp) {
addSecondPass(sp, false);
}
| public void addSecondPass(SecondPass sp,
boolean onTopOfTheQueue) {
if (onTopOfTheQueue) {
secondPasses.add(0, sp);
}
else {
secondPasses.add(sp);
}
}
| public Table addTable(String schema,
String catalog,
String name,
String subselect,
boolean isAbstract) {
String key = subselect==null ?
Table.qualify(catalog, schema, name) :
subselect;
Table table = (Table) tables.get(key);
if (table == null) {
table = new Table();
table.setAbstract(isAbstract);
table.setName(name);
table.setSchema(schema);
table.setCatalog(catalog);
table.setSubselect(subselect);
tables.put(key, table);
}
else {
if (!isAbstract) table.setAbstract(false);
}
return table;
}
| public void addTableBinding(String schema,
String catalog,
String logicalName,
String physicalName,
Table denormalizedSuperTable) {
String key = buildTableNameKey( schema, catalog, physicalName );
TableDescription tableDescription = new TableDescription(
logicalName, denormalizedSuperTable
);
TableDescription oldDescriptor = (TableDescription) tableNameBinding.put( key, tableDescription );
if ( oldDescriptor != null && ! oldDescriptor.logicalName.equals( logicalName ) ) {
//TODO possibly relax that
throw new MappingException("Same physical table name reference several logical table names: "
+ physicalName + " = > " + "'" + oldDescriptor.logicalName + "' and '" + logicalName + "'");
}
}
| public void addToExtendsQueue(ExtendsQueueEntry entry) {
extendsQueue.put( entry, null );
}
| public void addTypeDef(String typeName,
String typeClass,
Properties paramMap) {
TypeDef def = new TypeDef(typeClass, paramMap);
typeDefs.put(typeName, def);
log.debug("Added " + typeName + " with class " + typeClass);
}
| void addUniquePropertyReference(String referencedClass,
String propertyName) {
PropertyReference upr = new PropertyReference();
upr.referencedClass = referencedClass;
upr.propertyName = propertyName;
upr.unique = true;
propertyReferences.add(upr);
}
| public String getCatalogName() {
return catalogName;
}
| public PersistentClass getClass(String className) {
return (PersistentClass) classes.get(className);
}
| public Collection getCollection(String role) {
return (Collection) collections.get(role);
}
| public String getDefaultAccess() {
return defaultAccess;
}
| public String getDefaultCascade() {
return defaultCascade;
}
| public String getDefaultPackage() {
return defaultPackage;
}
| public FilterDefinition getFilterDefinition(String name) {
return (FilterDefinition) filterDefinitions.get(name);
}
| public Map getFilterDefinitions() {
return filterDefinitions;
}
| public String getLogicalColumnName(String physicalName,
Table table) {
String logical = null;
Table currentTable = table;
TableDescription description = null;
do {
ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
if (binding != null) {
logical = (String) binding.physicalToLogical.get( physicalName );
}
String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
description = (TableDescription) tableNameBinding.get(key);
if (description != null) currentTable = description.denormalizedSupertable;
}
while (logical == null && currentTable != null && description != null);
if (logical == null) {
throw new MappingException( "Unable to find logical column name from physical name "
+ physicalName + " in table " + table.getName() );
}
return logical;
}
| public String getLogicalTableName(Table table) {
return getLogicalTableName( table.getQuotedSchema(), table.getCatalog(), table.getQuotedName() );
}
| public NamingStrategy getNamingStrategy() {
return namingStrategy;
}
| public String getPhysicalColumnName(String logicalName,
Table table) {
logicalName = logicalName.toLowerCase();
String finalName = null;
Table currentTable = table;
do {
ColumnNames binding = (ColumnNames) columnNameBindingPerTable.get(currentTable);
if (binding != null) {
finalName = (String) binding.logicalToPhysical.get( logicalName );
}
String key = buildTableNameKey( currentTable.getSchema(), currentTable.getCatalog(), currentTable.getName() );
TableDescription description = (TableDescription) tableNameBinding.get(key);
if (description != null) currentTable = description.denormalizedSupertable;
}
while (finalName == null && currentTable != null);
if (finalName == null) {
throw new MappingException( "Unable to find column with logical name "
+ logicalName + " in table " + table.getName() );
}
return finalName;
}
| public NamedQueryDefinition getQuery(String name) {
return (NamedQueryDefinition) queries.get(name);
}
| public ResultSetMappingDefinition getResultSetMapping(String name) {
return (ResultSetMappingDefinition) resultSetMappings.get(name);
}
| public String getSchemaName() {
return schemaName;
}
| public Table getTable(String schema,
String catalog,
String name) {
String key = Table.qualify(catalog, schema, name);
return (Table) tables.get(key);
}
| public TypeDef getTypeDef(String typeName) {
return (TypeDef) typeDefs.get(typeName);
}
| public boolean isAutoImport() {
return autoImport;
}
| public boolean isDefaultLazy() {
return defaultLazy;
}
| public Iterator iterateCollections() {
return collections.values().iterator();
}
| public Iterator iterateTables() {
return tables.values().iterator();
}
| public PersistentClass locatePersistentClassByEntityName(String entityName) {
PersistentClass persistentClass = ( PersistentClass ) classes.get( entityName );
if ( persistentClass == null ) {
String actualEntityName = ( String ) imports.get( entityName );
if ( StringHelper.isNotEmpty( actualEntityName ) ) {
persistentClass = ( PersistentClass ) classes.get( actualEntityName );
}
}
return persistentClass;
}
| public void setAutoImport(boolean autoImport) {
this.autoImport = autoImport;
}
| public void setCatalogName(String catalogName) {
this.catalogName = catalogName;
}
| public void setDefaultAccess(String defaultAccess) {
this.defaultAccess = defaultAccess;
}
sets the default access strategy | public void setDefaultCascade(String defaultCascade) {
this.defaultCascade = defaultCascade;
}
| public void setDefaultLazy(boolean defaultLazy) {
this.defaultLazy = defaultLazy;
}
| public void setDefaultPackage(String defaultPackage) {
this.defaultPackage = defaultPackage;
}
| public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
|
|