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:

  1. bounded state : this is information which is indeed scoped by a single mapping
  2. unbounded state : this is information which is Configuration wide (think of metadata repository)
  3. transient state : state which changed at its own pace (naming strategy)
  • 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

      void setNamingStrategy(NamingStrategy namingStrategy)
      Set the current naming strategy.
      Parameters:
      namingStrategy - The naming strategy to use.
    • getPersisterClassProvider

      PersisterClassProvider getPersisterClassProvider()
      Get the current persister class provider implementation
    • setPersisterClassProvider

      void setPersisterClassProvider(PersisterClassProvider persisterClassProvider)
      Set the current persister class provider implementation
    • getSchemaName

      String getSchemaName()
      Returns the currently bound default schema name.
      Returns:
      The currently bound schema name
    • setSchemaName

      void setSchemaName(String schemaName)
      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

      void setCatalogName(String catalogName)
      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

      void setDefaultPackage(String defaultPackage)
      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

      void setDefaultCascade(String defaultCascade)
      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

      void setDefaultAccess(String defaultAccess)
      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

      PersistentClass getClass(String entityName)
      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

      PersistentClass locatePersistentClassByEntityName(String entityName)
      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

      void addClass(PersistentClass persistentClass) throws DuplicateMappingException
      Add entity mapping metadata.
      Parameters:
      persistentClass - The entity metadata
      Throws:
      DuplicateMappingException - Indicates there4 was already an extry corresponding to the given entity name.
    • addImport

      void addImport(String entityName, String rename) throws DuplicateMappingException
      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

      Collection getCollection(String role)
      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

      void addCollection(Collection collection) throws DuplicateMappingException
      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

      Table getTable(String schema, String catalog, String name)
      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

      Iterator<Table> iterateTables()
      Returns an iterator over table metadata.
      Returns:
      Iterator over table metadata.
    • addTable

      Table addTable(String schema, String catalog, String name, String subselect, boolean isAbstract)
      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 name
      subselect - 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 name
      isAbstract - 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

      NamedQueryDefinition getQuery(String name)
      Get named query metadata by name.
      Parameters:
      name - The named query name
      Returns:
      The query metadata, or null.
    • addQuery

      void addQuery(String name, NamedQueryDefinition query) throws DuplicateMappingException
      Adds metadata for a named query to this repository.
      Parameters:
      name - The name
      query - The metadata
      Throws:
      DuplicateMappingException - If a query already exists with that name.
    • getSQLQuery

      NamedSQLQueryDefinition getSQLQuery(String name)
      Get named SQL query metadata.
      Parameters:
      name - The named SQL query name.
      Returns:
      The meatdata, or null if none found.
    • addSQLQuery

      void addSQLQuery(String name, NamedSQLQueryDefinition query) throws DuplicateMappingException
      Adds metadata for a named SQL query to this repository.
      Parameters:
      name - The name
      query - The metadata
      Throws:
      DuplicateMappingException - If a query already exists with that name.
    • getResultSetMapping

      ResultSetMappingDefinition getResultSetMapping(String name)
      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

      TypeDef getTypeDef(String typeName)
      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

      void addTypeDef(String typeName, String typeClass, Properties paramMap)
      Adds a type definition to this metadata repository.
      Parameters:
      typeName - The type name.
      typeClass - The class implementing the Type contract.
      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

      FilterDefinition getFilterDefinition(String name)
      Retrieves a filter definition by name.
      Parameters:
      name - The name of the filter definition to retrieve.
      Returns:
      The filter definition, or null.
    • addFilterDefinition

      void addFilterDefinition(FilterDefinition definition)
      Adds a filter definition to this repository.
      Parameters:
      definition - The filter definition to add.
    • findOrCreateFetchProfile

      FetchProfile 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).
      Parameters:
      name - The name of the profile.
      source - The source from which this profile is named.
      Returns:
      The fetch profile metadata.
    • iterateAuxliaryDatabaseObjects

      @Deprecated Iterator<AuxiliaryDatabaseObject> iterateAuxliaryDatabaseObjects()
      Deprecated.
      To fix misspelling; use iterateAuxiliaryDatabaseObjects() 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 ListIterator<AuxiliaryDatabaseObject> iterateAuxliaryDatabaseObjectsInReverse()
      Deprecated.
      To fix misspelling; use iterateAuxiliaryDatabaseObjectsInReverse() instead
    • iterateAuxiliaryDatabaseObjectsInReverse

      ListIterator<AuxiliaryDatabaseObject> iterateAuxiliaryDatabaseObjectsInReverse()
      Same as iterateAuxiliaryDatabaseObjects() except that here the iterator is reversed.
      Returns:
      The reversed iterator.
    • addAuxiliaryDatabaseObject

      void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxiliaryDatabaseObject)
      Add metadata pertaining to an auxiliary database object to this repository.
      Parameters:
      auxiliaryDatabaseObject - The metadata.
    • getLogicalTableName

      String getLogicalTableName(Table table) throws MappingException
      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

      String getPhysicalColumnName(String logicalName, Table table) throws MappingException
      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

      String getLogicalColumnName(String physicalName, Table table) throws MappingException
      Find the logical column name against whcih the given physical column name was bound within the given table.
      Parameters:
      physicalName - The physical column name
      table - The table metadata.
      Returns:
      The logical column name.
      Throws:
      MappingException - Indicates that no such binding was found.
    • addSecondPass

      void addSecondPass(SecondPass sp)
      Adds a second-pass to the end of the current queue.
      Parameters:
      sp - The second pass to add.
    • addSecondPass

      void addSecondPass(SecondPass sp, boolean onTopOfTheQueue)
      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

      void addPropertyReference(String referencedClass, String propertyName)
      Adds a property reference binding to this repository.
      Parameters:
      referencedClass - The referenced entity name.
      propertyName - The referenced property name.
    • addUniquePropertyReference

      void addUniquePropertyReference(String referencedClass, String propertyName)
      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

      void addToExtendsQueue(ExtendsQueueEntry entry)
      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

      void addMappedSuperclass(Class type, MappedSuperclass mappedSuperclass)
      add a new MappedSuperclass This should not be called if the MappedSuperclass already exists (it would be erased)
      Parameters:
      type - type corresponding to the Mappedsuperclass
      mappedSuperclass - MappedSuperclass
    • getMappedSuperclass

      MappedSuperclass getMappedSuperclass(Class type)
      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

      void addDefaultGenerator(IdGenerator generator)
      Adds a default id generator.
      Parameters:
      generator - The id generator
    • getGenerator

      IdGenerator getGenerator(String name)
      Retrieve the id-generator by name.
      Parameters:
      name - The generator name.
      Returns:
      The generator, or null.
    • getGenerator

      IdGenerator getGenerator(String name, Map<String,IdGenerator> localGenerators)
      Try to find the generator from the localGenerators and then from the global generator list
      Parameters:
      name - generator name
      localGenerators - local generators
      Returns:
      the appropriate idgenerator or null if not found
    • addGenerator

      void addGenerator(IdGenerator generator)
      Add a generator.
      Parameters:
      generator - The generator to add.
    • addGeneratorTable

      void addGeneratorTable(String name, Properties params)
      Add a generator table properties.
      Parameters:
      name - The generator name
      params - The generator table properties.
    • getGeneratorTableProperties

      Properties getGeneratorTableProperties(String name, Map<String,Properties> localGeneratorTables)
      Retrieve the properties related to a generator table.
      Parameters:
      name - generator name
      localGeneratorTables - local generator tables
      Returns:
      The properties, or null.
    • getJoins

      Map<String,Join> getJoins(String entityName)
      Retrieve join metadata for a particular persistent entity.
      Parameters:
      entityName - The entity name
      Returns:
      The join metadata
    • addJoins

      void addJoins(PersistentClass persistentClass, Map<String,Join> joins)
      Add join metadata for a persistent entity.
      Parameters:
      persistentClass - The persistent entity metadata.
      joins - The join metadata to add.
      Throws:
      MappingException
    • getClassType

      AnnotatedClassType getClassType(XClass clazz)
      Get and maintain a cache of class type.
      Parameters:
      clazz - The XClass mapping
      Returns:
      The class type.
    • addClassType

      AnnotatedClassType addClassType(XClass clazz)
      FIXME should be private but will this break things? Add a class type.
      Parameters:
      clazz - The XClass mapping.
      Returns:
      The class type.
    • getTableUniqueConstraints

      Map<Table,List<String[]>> getTableUniqueConstraints()
      Deprecated.
    • getUniqueConstraintHoldersByTable

      Map<Table,List<UniqueConstraintHolder>> getUniqueConstraintHoldersByTable()
    • addUniqueConstraints

      void addUniqueConstraints(Table table, List uniqueConstraints)
    • addUniqueConstraintHolders

      void addUniqueConstraintHolders(Table table, List<UniqueConstraintHolder> uniqueConstraintHolders)
    • addMappedBy

      void addMappedBy(String entityName, String propertyName, String inversePropertyName)
    • getFromMappedBy

      String getFromMappedBy(String entityName, String propertyName)
    • addPropertyReferencedAssociation

      void addPropertyReferencedAssociation(String entityName, String propertyName, String propertyRef)
    • getPropertyReferencedAssociation

      String getPropertyReferencedAssociation(String entityName, String propertyName)
    • getReflectionManager

      ReflectionManager getReflectionManager()
    • addDefaultQuery

      void addDefaultQuery(String name, NamedQueryDefinition query)
    • addDefaultSQLQuery

      void addDefaultSQLQuery(String name, NamedSQLQueryDefinition query)
    • addDefaultResultSetMapping

      void addDefaultResultSetMapping(ResultSetMappingDefinition definition)
    • getClasses

      Map getClasses()
    • addAnyMetaDef

      void addAnyMetaDef(AnyMetaDef defAnn) throws AnnotationException
      Throws:
      AnnotationException
    • getAnyMetaDef

      AnyMetaDef getAnyMetaDef(String name)
    • isInSecondPass

      boolean isInSecondPass()
    • getPropertyAnnotatedWithMapsId

      PropertyData getPropertyAnnotatedWithMapsId(XClass entityType, String propertyName)
      Return the property annotated with @MapsId("propertyName") if any. Null otherwise
    • addPropertyAnnotatedWithMapsId

      void addPropertyAnnotatedWithMapsId(XClass entityType, PropertyData property)
    • 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 the Configuration.USE_NEW_ID_GENERATOR_MAPPINGS setting.
      Returns:
      True if the new generators should be used, false otherwise.
    • getPropertyAnnotatedWithIdAndToOne

      PropertyData getPropertyAnnotatedWithIdAndToOne(XClass entityType, String propertyName)
      Return the property annotated with @ToOne and @Id if any. Null otherwise
    • addToOneAndIdProperty

      void addToOneAndIdProperty(XClass entity, PropertyData property)