Package org.hibernate.cfg
Interface Mappings
- All Known Subinterfaces:
ExtendedMappings
- All Known Implementing Classes:
AnnotationConfiguration.ExtendedMappingsImpl,Configuration.MappingsImpl
public interface Mappings
A collection of mappings from classes and collections to relational database tables. Represents a single
<hibernate-mapping> element.
todo : the statement about this representing a single mapping element is simply not true if it was ever the case.
this contract actually represents 3 scopes of information:
- bounded state : this is information which is indeed scoped by a single mapping
- unbounded state : this is information which is Configuration wide (think of metadata repository)
- transient state : state which changed at its own pace (naming strategy)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classRepresents a property-ref mapping. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnyMetaDef(AnyMetaDef defAnn) voidaddAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject) Add metadata pertaining to an auxiliary database object to this repository.voidaddClass(PersistentClass persistentClass) Add entity mapping metadata.addClassType(XClass clazz) FIXME should be private but will this break things? Add a class type.voidaddCollection(Collection collection) Add collection mapping metadata to this repository.voidaddColumnBinding(String logicalName, Column physicalColumn, Table table) Binds the given 'physicalColumn' to the give 'logicalName' within the given 'table'.voidaddDefaultGenerator(IdGenerator generator) Adds a default id generator.voidaddDefaultQuery(String name, NamedQueryDefinition query) voidaddDefaultResultSetMapping(ResultSetMappingDefinition definition) voidaddDefaultSQLQuery(String name, NamedSQLQueryDefinition query) addDenormalizedTable(String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) Adds a 'denormalized table' to this repository.voidaddFilterDefinition(FilterDefinition definition) Adds a filter definition to this repository.voidaddGenerator(IdGenerator generator) Add a generator.voidaddGeneratorTable(String name, Properties params) Add a generator table properties.voidAdds an import (HQL entity rename) to the repository.voidaddJoins(PersistentClass persistentClass, Map<String, Join> joins) Add join metadata for a persistent entity.voidaddMappedBy(String entityName, String propertyName, String inversePropertyName) voidaddMappedSuperclass(Class type, MappedSuperclass mappedSuperclass) add a new MappedSuperclass This should not be called if the MappedSuperclass already exists (it would be erased)voidaddPropertyAnnotatedWithMapsId(XClass entityType, PropertyData property) voidaddPropertyAnnotatedWithMapsIdSpecj(XClass entityType, PropertyData property, String mapsIdValue) voidaddPropertyReference(String referencedClass, String propertyName) Adds a property reference binding to this repository.voidaddPropertyReferencedAssociation(String entityName, String propertyName, String propertyRef) voidaddQuery(String name, NamedQueryDefinition query) Adds metadata for a named query to this repository.voidaddResultSetMapping(ResultSetMappingDefinition sqlResultSetMapping) Adds the metadata for a named SQL result set mapping to this repository.voidAdds a second-pass to the end of the current queue.voidaddSecondPass(SecondPass sp, boolean onTopOfTheQueue) Adds a second pass.voidaddSQLQuery(String name, NamedSQLQueryDefinition query) Adds metadata for a named SQL query to this repository.Adds table metadata to this repository returning the created metadata instance.voidaddTableBinding(String schema, String catalog, String logicalName, String physicalName, Table denormalizedSuperTable) Adds a table binding to this repository.voidAdds an entry to the extends queue queue.voidaddToOneAndIdProperty(XClass entity, PropertyData property) voidaddTypeDef(String typeName, String typeClass, Properties paramMap) Adds a type definition to this metadata repository.voidaddUniqueConstraintHolders(Table table, List<UniqueConstraintHolder> uniqueConstraintHolders) voidaddUniqueConstraints(Table table, List uniqueConstraints) Deprecated.voidaddUniquePropertyReference(String referencedClass, String propertyName) Adds a property reference binding to this repository where said proeprty reference is marked as unique.findOrCreateFetchProfile(String name, MetadataSource source) Retrieves a fetch profile by either finding one currently in this repository matching the given name or by creating one (and adding it).getAnyMetaDef(String name) Returns the currently bound default catalog name.Retrieves the entity mapping metadata for the given entity name.getClassType(XClass clazz) Get and maintain a cache of class type.getCollection(String role) Retrieves the collection mapping metadata for the given collection role.Retrieve the configuration properties currently in effect.Get the current default property access style.Get the current default cascade style.Get the currently bound default package name.getFilterDefinition(String name) Retrieves a filter definition by name.Retrieves the copmplete map of filter definitions.getFromMappedBy(String entityName, String propertyName) getGenerator(String name) Retrieve the id-generator by name.getGenerator(String name, Map<String, IdGenerator> localGenerators) Try to find the generator from the localGenerators and then from the global generator listgetGeneratorTableProperties(String name, Map<String, Properties> localGeneratorTables) Retrieve the properties related to a generator table.Retrieve the IdentifierGeneratorFactory in effect for this mapping.Retrieve join metadata for a particular persistent entity.getLogicalColumnName(String physicalName, Table table) Find the logical column name against whcih the given physical column name was bound within the given table.getLogicalTableName(Table table) Get the logical table name mapped for the given physical table.getMappedSuperclass(Class type) Get a MappedSuperclass or null if not mappedGet the current naming strategy.Retrieve the database identifier normalizer for this context.Get the current persister class provider implementationgetPhysicalColumnName(String logicalName, Table table) Find the physical column name for the given logical column name within the given table.getPropertyAnnotatedWithIdAndToOne(XClass entityType, String propertyName) Return the property annotated with @ToOne and @Id if any.getPropertyAnnotatedWithMapsId(XClass entityType, String propertyName) Return the property annotated with @MapsId("propertyName") if any.getPropertyReferencedAssociation(String entityName, String propertyName) Get named query metadata by name.getResultSetMapping(String name) Get the metadata for a named SQL result set mapping.Returns the currently bound default schema name.getSQLQuery(String name) Get named SQL query metadata.Returns the named table metadata.Deprecated.UsegetUniqueConstraintHoldersByTable()insteadgetTypeDef(String typeName) Retrieve a type definition by name.Retrieve the type resolver in effect.booleanDetermine whether auto importing of entity names is currently enabled.booleanDetermine whether default laziness is currently enabled.booleanbooleanRetrieves an iterator over the metadata pertaining to all auxiliary database objects int this repository.Same asiterateAuxiliaryDatabaseObjects()except that here the iterator is reversed.Deprecated.To fix misspelling; useiterateAuxiliaryDatabaseObjects()insteadDeprecated.To fix misspelling; useiterateAuxiliaryDatabaseObjectsInReverse()insteadRetrieves an iterator over the entity metadata present in this repository.Returns an iterator over collection metadata.Returns an iterator over table metadata.locatePersistentClassByEntityName(String entityName) Retrieves the entity mapping metadata for the given entity name, potentially accounting for imports.voidsetAutoImport(boolean autoImport) Set whether to enable auto importing of entity names.voidsetCatalogName(String catalogName) Sets the currently bound default catalog name.voidsetDefaultAccess(String defaultAccess) Sets the current default property access style.voidsetDefaultCascade(String defaultCascade) Sets the current default cascade style.voidsetDefaultLazy(boolean defaultLazy) Set whether to enable default laziness.voidsetDefaultPackage(String defaultPackage) Set the current default package name.voidsetNamingStrategy(NamingStrategy namingStrategy) Set the current naming strategy.voidsetPersisterClassProvider(PersisterClassProvider persisterClassProvider) Set the current persister class provider implementationvoidsetSchemaName(String schemaName) Sets the currently bound default schema name.booleanShould we use the new generator strategy mappings.
-
Method Details
-
getTypeResolver
TypeResolver getTypeResolver()Retrieve the type resolver in effect.- Returns:
- The type resolver.
-
getNamingStrategy
NamingStrategy getNamingStrategy()Get the current naming strategy.- Returns:
- The current naming strategy.
-
setNamingStrategy
Set the current naming strategy.- Parameters:
namingStrategy- The naming strategy to use.
-
getPersisterClassProvider
PersisterClassProvider getPersisterClassProvider()Get the current persister class provider implementation -
setPersisterClassProvider
Set the current persister class provider implementation -
getSchemaName
String getSchemaName()Returns the currently bound default schema name.- Returns:
- The currently bound schema name
-
setSchemaName
Sets the currently bound default schema name.- Parameters:
schemaName- The schema name to bind as the current default.
-
getCatalogName
String getCatalogName()Returns the currently bound default catalog name.- Returns:
- The currently bound catalog name, or null if none.
-
setCatalogName
Sets the currently bound default catalog name.- Parameters:
catalogName- The catalog name to use as the current default.
-
getDefaultPackage
String getDefaultPackage()Get the currently bound default package name.- Returns:
- The currently bound default package name
-
setDefaultPackage
Set the current default package name.- Parameters:
defaultPackage- The package name to set as the current default.
-
isAutoImport
boolean isAutoImport()Determine whether auto importing of entity names is currently enabled.- Returns:
- True if currently enabled; false otherwise.
-
setAutoImport
void setAutoImport(boolean autoImport) Set whether to enable auto importing of entity names.- Parameters:
autoImport- True to enable; false to diasable.- See Also:
-
isDefaultLazy
boolean isDefaultLazy()Determine whether default laziness is currently enabled.- Returns:
- True if enabled, false otherwise.
-
setDefaultLazy
void setDefaultLazy(boolean defaultLazy) Set whether to enable default laziness.- Parameters:
defaultLazy- True to enable, false to disable.
-
getDefaultCascade
String getDefaultCascade()Get the current default cascade style.- Returns:
- The current default cascade style.
-
setDefaultCascade
Sets the current default cascade style. .- Parameters:
defaultCascade- The cascade style to set as the current default.
-
getDefaultAccess
String getDefaultAccess()Get the current default property access style.- Returns:
- The current default property access style.
-
setDefaultAccess
Sets the current default property access style.- Parameters:
defaultAccess- The access style to use as the current default.
-
iterateClasses
Iterator<PersistentClass> iterateClasses()Retrieves an iterator over the entity metadata present in this repository.- Returns:
- Iterator over class metadata.
-
getClass
Retrieves the entity mapping metadata for the given entity name.- Parameters:
entityName- The entity name for which to retrieve the metadata.- Returns:
- The entity mapping metadata, or null if none found matching given entity name.
-
locatePersistentClassByEntityName
Retrieves the entity mapping metadata for the given entity name, potentially accounting for imports.- Parameters:
entityName- The entity name for which to retrieve the metadata.- Returns:
- The entity mapping metadata, or null if none found matching given entity name.
-
addClass
Add entity mapping metadata.- Parameters:
persistentClass- The entity metadata- Throws:
DuplicateMappingException- Indicates there4 was already an extry corresponding to the given entity name.
-
addImport
Adds an import (HQL entity rename) to the repository.- Parameters:
entityName- The entity name being renamed.rename- The rename- Throws:
DuplicateMappingException- If rename already is mapped to another entity name in this repository.
-
getCollection
Retrieves the collection mapping metadata for the given collection role.- Parameters:
role- The collection role for which to retrieve the metadata.- Returns:
- The collection mapping metadata, or null if no matching collection role found.
-
iterateCollections
Iterator<Collection> iterateCollections()Returns an iterator over collection metadata.- Returns:
- Iterator over collection metadata.
-
addCollection
Add collection mapping metadata to this repository.- Parameters:
collection- The collection metadata- Throws:
DuplicateMappingException- Indicates there was already an entry corresponding to the given collection role
-
getTable
Returns the named table metadata.- Parameters:
schema- The named schema in which the table belongs (or null).catalog- The named catalog in which the table belongs (or null).name- The table name- Returns:
- The table metadata, or null.
-
iterateTables
Returns an iterator over table metadata.- Returns:
- Iterator over table metadata.
-
addTable
Adds table metadata to this repository returning the created metadata instance.- Parameters:
schema- The named schema in which the table belongs (or null).catalog- The named catalog in which the table belongs (or null).name- The table namesubselect- A select statement which defines a logical table, much like a DB view.isAbstract- Is the table abstract (i.e. not really existing in the DB)?- Returns:
- The created table metadata, or the existing reference.
-
addDenormalizedTable
Table addDenormalizedTable(String schema, String catalog, String name, boolean isAbstract, String subselect, Table includedTable) throws DuplicateMappingException Adds a 'denormalized table' to this repository.- Parameters:
schema- The named schema in which the table belongs (or null).catalog- The named catalog in which the table belongs (or null).name- The table nameisAbstract- Is the table abstract (i.e. not really existing in the DB)?subselect- A select statement which defines a logical table, much like a DB view.includedTable- ???- Returns:
- The created table metadata.
- Throws:
DuplicateMappingException- If such a table mapping already exists.
-
getQuery
Get named query metadata by name.- Parameters:
name- The named query name- Returns:
- The query metadata, or null.
-
addQuery
Adds metadata for a named query to this repository.- Parameters:
name- The namequery- The metadata- Throws:
DuplicateMappingException- If a query already exists with that name.
-
getSQLQuery
Get named SQL query metadata.- Parameters:
name- The named SQL query name.- Returns:
- The meatdata, or null if none found.
-
addSQLQuery
Adds metadata for a named SQL query to this repository.- Parameters:
name- The namequery- The metadata- Throws:
DuplicateMappingException- If a query already exists with that name.
-
getResultSetMapping
Get the metadata for a named SQL result set mapping.- Parameters:
name- The mapping name.- Returns:
- The SQL result set mapping metadat, or null if none found.
-
addResultSetMapping
void addResultSetMapping(ResultSetMappingDefinition sqlResultSetMapping) throws DuplicateMappingException Adds the metadata for a named SQL result set mapping to this repository.- Parameters:
sqlResultSetMapping- The metadata- Throws:
DuplicateMappingException- If metadata for another SQL result mapping was already found under the given name.
-
getTypeDef
Retrieve a type definition by name.- Parameters:
typeName- The name of the type definition to retrieve.- Returns:
- The type definition, or null if none found.
-
addTypeDef
Adds a type definition to this metadata repository.- Parameters:
typeName- The type name.typeClass- The class implementing theTypecontract.paramMap- Map of parameters to be used to configure the type after instantiation.
-
getFilterDefinitions
Map getFilterDefinitions()Retrieves the copmplete map of filter definitions.- Returns:
- The filter definition map.
-
getFilterDefinition
Retrieves a filter definition by name.- Parameters:
name- The name of the filter definition to retrieve.- Returns:
- The filter definition, or null.
-
addFilterDefinition
Adds a filter definition to this repository.- Parameters:
definition- The filter definition to add.
-
findOrCreateFetchProfile
Retrieves a fetch profile by either finding one currently in this repository matching the given name or by creating one (and adding it).- Parameters:
name- The name of the profile.source- The source from which this profile is named.- Returns:
- The fetch profile metadata.
-
iterateAuxliaryDatabaseObjects
Deprecated.To fix misspelling; useiterateAuxiliaryDatabaseObjects()instead -
iterateAuxiliaryDatabaseObjects
Iterator<AuxiliaryDatabaseObject> iterateAuxiliaryDatabaseObjects()Retrieves an iterator over the metadata pertaining to all auxiliary database objects int this repository.- Returns:
- Iterator over the auxiliary database object metadata.
-
iterateAuxliaryDatabaseObjectsInReverse
Deprecated.To fix misspelling; useiterateAuxiliaryDatabaseObjectsInReverse()instead -
iterateAuxiliaryDatabaseObjectsInReverse
ListIterator<AuxiliaryDatabaseObject> iterateAuxiliaryDatabaseObjectsInReverse()Same asiterateAuxiliaryDatabaseObjects()except that here the iterator is reversed.- Returns:
- The reversed iterator.
-
addAuxiliaryDatabaseObject
Add metadata pertaining to an auxiliary database object to this repository.- Parameters:
auxiliaryDatabaseObject- The metadata.
-
getLogicalTableName
Get the logical table name mapped for the given physical table.- Parameters:
table- The table for which to determine the logical name.- Returns:
- The logical name.
- Throws:
MappingException- Indicates that no logical name was bound for the given physical table.
-
addTableBinding
void addTableBinding(String schema, String catalog, String logicalName, String physicalName, Table denormalizedSuperTable) throws DuplicateMappingException Adds a table binding to this repository.- Parameters:
schema- The schema in which the table belongs (may be null).catalog- The catalog in which the table belongs (may be null).logicalName- The logical table name.physicalName- The physical table name.denormalizedSuperTable- ???- Throws:
DuplicateMappingException- Indicates physical table was already bound to another logical name.
-
addColumnBinding
void addColumnBinding(String logicalName, Column physicalColumn, Table table) throws DuplicateMappingException Binds the given 'physicalColumn' to the give 'logicalName' within the given 'table'.- Parameters:
logicalName- The logical column name binding.physicalColumn- The physical column metadata.table- The table metadata.- Throws:
DuplicateMappingException- Indicates a duplicate binding for either the physical column name or the logical column name.
-
getPhysicalColumnName
Find the physical column name for the given logical column name within the given table.- Parameters:
logicalName- The logical name binding.table- The table metatdata.- Returns:
- The physical column name.
- Throws:
MappingException- Indicates that no such binding was found.
-
getLogicalColumnName
Find the logical column name against whcih the given physical column name was bound within the given table.- Parameters:
physicalName- The physical column nametable- The table metadata.- Returns:
- The logical column name.
- Throws:
MappingException- Indicates that no such binding was found.
-
addSecondPass
Adds a second-pass to the end of the current queue.- Parameters:
sp- The second pass to add.
-
addSecondPass
Adds a second pass.- Parameters:
sp- The second pass to add.onTopOfTheQueue- True to add to the beginning of the queue; false to add to the end.
-
addPropertyReference
Adds a property reference binding to this repository.- Parameters:
referencedClass- The referenced entity name.propertyName- The referenced property name.
-
addUniquePropertyReference
Adds a property reference binding to this repository where said proeprty reference is marked as unique.- Parameters:
referencedClass- The referenced entity name.propertyName- The referenced property name.
-
addToExtendsQueue
Adds an entry to the extends queue queue.- Parameters:
entry- The entry to add.
-
getIdentifierGeneratorFactory
DefaultIdentifierGeneratorFactory getIdentifierGeneratorFactory()Retrieve the IdentifierGeneratorFactory in effect for this mapping.- Returns:
- The IdentifierGeneratorFactory
-
addMappedSuperclass
add a new MappedSuperclass This should not be called if the MappedSuperclass already exists (it would be erased)- Parameters:
type- type corresponding to the MappedsuperclassmappedSuperclass- MappedSuperclass
-
getMappedSuperclass
Get a MappedSuperclass or null if not mapped- Parameters:
type- class corresponding to the MappedSuperclass- Returns:
- the MappedSuperclass
-
getObjectNameNormalizer
ObjectNameNormalizer getObjectNameNormalizer()Retrieve the database identifier normalizer for this context.- Returns:
- The normalizer.
-
getConfigurationProperties
Properties getConfigurationProperties()Retrieve the configuration properties currently in effect.- Returns:
- The configuration properties
-
addDefaultGenerator
Adds a default id generator.- Parameters:
generator- The id generator
-
getGenerator
Retrieve the id-generator by name.- Parameters:
name- The generator name.- Returns:
- The generator, or null.
-
getGenerator
Try to find the generator from the localGenerators and then from the global generator list- Parameters:
name- generator namelocalGenerators- local generators- Returns:
- the appropriate idgenerator or null if not found
-
addGenerator
Add a generator.- Parameters:
generator- The generator to add.
-
addGeneratorTable
Add a generator table properties.- Parameters:
name- The generator nameparams- The generator table properties.
-
getGeneratorTableProperties
Retrieve the properties related to a generator table.- Parameters:
name- generator namelocalGeneratorTables- local generator tables- Returns:
- The properties, or null.
-
getJoins
Retrieve join metadata for a particular persistent entity.- Parameters:
entityName- The entity name- Returns:
- The join metadata
-
addJoins
Add join metadata for a persistent entity.- Parameters:
persistentClass- The persistent entity metadata.joins- The join metadata to add.- Throws:
MappingException
-
getClassType
Get and maintain a cache of class type.- Parameters:
clazz- The XClass mapping- Returns:
- The class type.
-
addClassType
FIXME should be private but will this break things? Add a class type.- Parameters:
clazz- The XClass mapping.- Returns:
- The class type.
-
getTableUniqueConstraints
Deprecated.UsegetUniqueConstraintHoldersByTable()instead -
getUniqueConstraintHoldersByTable
Map<Table,List<UniqueConstraintHolder>> getUniqueConstraintHoldersByTable() -
addUniqueConstraints
-
addUniqueConstraintHolders
-
addMappedBy
-
getFromMappedBy
-
addPropertyReferencedAssociation
-
getPropertyReferencedAssociation
-
getReflectionManager
ReflectionManager getReflectionManager() -
addDefaultQuery
-
addDefaultSQLQuery
-
addDefaultResultSetMapping
-
getClasses
Map getClasses() -
addAnyMetaDef
- Throws:
AnnotationException
-
getAnyMetaDef
-
isInSecondPass
boolean isInSecondPass() -
getPropertyAnnotatedWithMapsId
Return the property annotated with @MapsId("propertyName") if any. Null otherwise -
addPropertyAnnotatedWithMapsId
-
addPropertyAnnotatedWithMapsIdSpecj
void addPropertyAnnotatedWithMapsIdSpecj(XClass entityType, PropertyData property, String mapsIdValue) -
isSpecjProprietarySyntaxEnabled
boolean isSpecjProprietarySyntaxEnabled() -
useNewGeneratorMappings
boolean useNewGeneratorMappings()Should we use the new generator strategy mappings. This is controlled by theConfiguration.USE_NEW_ID_GENERATOR_MAPPINGSsetting.- Returns:
- True if the new generators should be used, false otherwise.
-
getPropertyAnnotatedWithIdAndToOne
Return the property annotated with @ToOne and @Id if any. Null otherwise -
addToOneAndIdProperty
-
addUniqueConstraintHolders(org.hibernate.mapping.Table, java.util.List<org.hibernate.cfg.UniqueConstraintHolder>)instead