Class MappingRepository

java.lang.Object
org.apache.openjpa.meta.MetaDataRepository
org.apache.openjpa.jdbc.meta.MappingRepository
All Implemented Interfaces:
Serializable, PCRegistry.RegisterClassListener, Configurable, Closeable, MetaDataModes

public class MappingRepository extends MetaDataRepository
Repository of object/relational mapping information.
Author:
Abe White
See Also:
  • Constructor Details

    • MappingRepository

      public MappingRepository()
      Default constructor. Configure via Configurable.
  • Method Details

    • getDBDictionary

      public DBDictionary getDBDictionary()
      Convenient access to dictionary for mappings.
    • getMappingDefaults

      public MappingDefaults getMappingDefaults()
      Mapping defaults.
    • setMappingDefaults

      public void setMappingDefaults(MappingDefaults defaults)
      Mapping default.
    • getSchemaGroup

      public SchemaGroup getSchemaGroup()
      Representation of the database schema.
    • setSchemaGroup

      public void setSchemaGroup(SchemaGroup schema)
      Representation of the database schema.
    • getStrategyInstaller

      public StrategyInstaller getStrategyInstaller()
      Installs mapping strategies on components.
    • setStrategyInstaller

      public void setStrategyInstaller(StrategyInstaller installer)
      Installs mapping strategies on components.
    • getQueryResultMapping

      public QueryResultMapping getQueryResultMapping(Class<?> cls, String name, ClassLoader loader, boolean mustExist)
      Return the query result mapping for the given name.
    • getQueryResultMappings

      public QueryResultMapping[] getQueryResultMappings()
      Return all cached query result mappings.
    • getCachedQueryResultMapping

      public QueryResultMapping getCachedQueryResultMapping(Class cls, String name)
      Return the cached query result mapping with the given name, or null if none.
    • addQueryResultMapping

      public QueryResultMapping addQueryResultMapping(Class cls, String name)
      Add a query result mapping.
    • removeQueryResultMapping

      public boolean removeQueryResultMapping(QueryResultMapping res)
      Remove a query result mapping.
    • removeQueryResultMapping

      public boolean removeQueryResultMapping(Class cls, String name)
      Remove a query result mapping.
    • getMapping

      public ClassMapping getMapping(Class<?> cls, ClassLoader envLoader, boolean mustExist)
    • getMappings

      public ClassMapping[] getMappings()
    • getMapping

      public ClassMapping getMapping(Object oid, ClassLoader envLoader, boolean mustExist)
    • getImplementorMappings

      public ClassMapping[] getImplementorMappings(Class<?> cls, ClassLoader envLoader, boolean mustExist)
    • clear

      public void clear()
      Description copied from class: MetaDataRepository
      Clear the cache of parsed metadata. This method also clears the internal MetaDataFactory's cache.
      Overrides:
      clear in class MetaDataRepository
    • prepareMapping

      protected void prepareMapping(ClassMetaData meta)
      Description copied from class: MetaDataRepository
      Prepare metadata for mapping resolution. This method might map parts of the metadata that don't rely on other classes being mapped, but that other classes might rely on during their own mapping (for example, primary key fields). By default, this method only calls ClassMetaData.defineSuperclassFields(boolean).
      Overrides:
      prepareMapping in class MetaDataRepository
    • newClassMetaData

      protected ClassMetaData newClassMetaData(Class<?> type)
      Description copied from class: MetaDataRepository
      Create a new class metadata instance.
      Overrides:
      newClassMetaData in class MetaDataRepository
    • newClassMetaDataArray

      protected ClassMetaData[] newClassMetaDataArray(int length)
      Description copied from class: MetaDataRepository
      Create a new array of the proper class metadata subclass.
      Overrides:
      newClassMetaDataArray in class MetaDataRepository
    • newFieldMetaData

      protected FieldMetaData newFieldMetaData(String name, Class<?> type, ClassMetaData owner)
      Description copied from class: MetaDataRepository
      Create a new field metadata instance.
      Overrides:
      newFieldMetaData in class MetaDataRepository
    • newFieldMetaDataArray

      protected FieldMetaData[] newFieldMetaDataArray(int length)
      Description copied from class: MetaDataRepository
      Create a new array of the proper field metadata subclass.
      Overrides:
      newFieldMetaDataArray in class MetaDataRepository
    • newEmbeddedClassMetaData

      protected ClassMetaData newEmbeddedClassMetaData(ValueMetaData owner)
      Description copied from class: MetaDataRepository
      Create a new embedded class metadata instance.
      Overrides:
      newEmbeddedClassMetaData in class MetaDataRepository
    • newValueMetaData

      protected ValueMetaData newValueMetaData(FieldMetaData owner)
      Description copied from class: MetaDataRepository
      Create a new value metadata instance.
      Overrides:
      newValueMetaData in class MetaDataRepository
    • newSequenceMetaData

      protected SequenceMetaData newSequenceMetaData(String name)
      Description copied from class: MetaDataRepository
      Create a new sequence metadata instance.
      Overrides:
      newSequenceMetaData in class MetaDataRepository
    • newValueOrder

      protected Order newValueOrder(FieldMetaData owner, boolean asc)
      Description copied from class: MetaDataRepository
      Order by the field value.
      Overrides:
      newValueOrder in class MetaDataRepository
    • newRelatedFieldOrder

      protected Order newRelatedFieldOrder(FieldMetaData owner, FieldMetaData rel, boolean asc)
      Description copied from class: MetaDataRepository
      Order by a field of the related type.
      Overrides:
      newRelatedFieldOrder in class MetaDataRepository
    • newOrderArray

      protected Order[] newOrderArray(int size)
      Description copied from class: MetaDataRepository
      Create an array of orders of the given size.
      Overrides:
      newOrderArray in class MetaDataRepository
    • newVersion

      protected Version newVersion(ClassMapping cls)
      Create version metadata for the given class.
    • newDiscriminator

      protected Discriminator newDiscriminator(ClassMapping cls)
      Create discriminator metadata for the given class.
    • newMappingInfo

      protected ClassMappingInfo newMappingInfo(ClassMapping cls)
      Create raw mapping info for the given instance.
    • newMappingInfo

      protected FieldMappingInfo newMappingInfo(FieldMapping fm)
      Create raw mapping info for the given instance.
    • newMappingInfo

      protected ValueMappingInfo newMappingInfo(ValueMapping vm)
      Create raw mapping info for the given instance.
    • newMappingInfo

      protected VersionMappingInfo newMappingInfo(Version version)
      Create raw mapping info for the given instance.
    • newMappingInfo

      protected DiscriminatorMappingInfo newMappingInfo(Discriminator disc)
      Create raw mapping info for the given instance.
    • namedStrategy

      protected ClassStrategy namedStrategy(ClassMapping cls)
      Instantiate the given class' named strategy, or return null if no named strategy.
    • instantiateClassStrategy

      protected ClassStrategy instantiateClassStrategy(String name, ClassMapping cls)
      Return the strategy for the given name.
    • namedStrategy

      protected FieldStrategy namedStrategy(FieldMapping field, boolean installHandlers)
      Instantiate the given field's named strategy, or return null if no named strategy.
    • namedStrategy

      protected DiscriminatorStrategy namedStrategy(Discriminator discrim)
      Instantiate the given discriminator's named strategy, or return null if no named strategy.
    • instantiateDiscriminatorStrategy

      protected DiscriminatorStrategy instantiateDiscriminatorStrategy(String name, Discriminator discrim)
      Instantiate the given discriminator strategy.
    • namedStrategy

      protected VersionStrategy namedStrategy(Version version)
      Instantiate the given version's named strategy, or return null if no named strategy.
    • instantiateVersionStrategy

      protected VersionStrategy instantiateVersionStrategy(String name, Version version)
      Instantiate the given version strategy.
    • instantiateVersionStrategy

      protected VersionStrategy instantiateVersionStrategy(Class<?> strat, Version version, String props)
      Instantiate the given version strategy.
    • defaultStrategy

      protected ClassStrategy defaultStrategy(ClassMapping cls)
      Determine the default strategy to use for the given class. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected ClassStrategy defaultStrategy(ClassMapping cls, boolean adapting)
      Determine the default strategy to use for the given class. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected FieldStrategy defaultStrategy(FieldMapping field, boolean installHandlers)
      Determine the default strategy to use for the given field. Does not take into account the named or current strategy, if any. If a non-null strategy is returned, this method may as a side effect install value handlers on the field's value mappings.
    • defaultStrategy

      protected FieldStrategy defaultStrategy(FieldMapping field, boolean installHandlers, boolean adapting)
      Determine the default strategy to use for the given field. Does not take into account the named or current strategy, if any. If a non-null strategy is returned, this method may as a side effect install value handlers on the field's value mappings.
    • defaultTypeStrategy

      protected FieldStrategy defaultTypeStrategy(FieldMapping field, boolean installHandlers, boolean adapting)
      Return the built-in strategy for the field's type, or null if none.
    • handlerCollectionStrategy

      protected FieldStrategy handlerCollectionStrategy(FieldMapping field, ValueHandler ehandler, boolean installHandlers)
      Return the collection strategy for the given element handler, or null if none.
    • handlerMapStrategy

      protected FieldStrategy handlerMapStrategy(FieldMapping field, ValueHandler khandler, ValueHandler vhandler, boolean krel, boolean vrel, boolean installHandlers)
      Return the map strategy for the given key and value handlers / relations, or null if none.
    • isNonDefaultMappingAllowed

      public boolean isNonDefaultMappingAllowed()
    • isUniMTo1JT

      public boolean isUniMTo1JT(FieldMapping field)
    • isUni1To1JT

      public boolean isUni1To1JT(FieldMapping field)
    • isBi1To1JT

      public boolean isBi1To1JT(FieldMapping field)
    • isUni1ToMFK

      public boolean isUni1ToMFK(FieldMapping field)
    • isBiMTo1JT

      public boolean isBiMTo1JT(FieldMapping field)
    • getBi_1ToM_JoinTableField

      public FieldMapping getBi_1ToM_JoinTableField(FieldMapping field)
    • getBi_MTo1_JoinTableField

      public FieldMapping getBi_MTo1_JoinTableField(FieldMapping field)
    • hasJoinColumn

      public boolean hasJoinColumn(FieldMapping field)
    • hasJoinTable

      public boolean hasJoinTable(FieldMapping field)
    • isBidirectional

      public boolean isBidirectional(FieldMapping field)
    • namedHandler

      protected ValueHandler namedHandler(ValueMapping val)
      Instantiate the given value's named handler, or return null if no named handler.
    • defaultHandler

      protected ValueHandler defaultHandler(ValueMapping val)
      Determine the default handler to use for the given value. Does not take into account the named handler, if any.
    • defaultHandler

      protected ValueHandler defaultHandler(ValueMapping val, boolean adapting)
      Determine the default handler to use for the given value. Does not take into account the named handler, if any.
    • defaultStrategy

      protected DiscriminatorStrategy defaultStrategy(Discriminator discrim)
      Determine the default strategy to use for the given discriminator. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected DiscriminatorStrategy defaultStrategy(Discriminator discrim, boolean adapting)
      Determine the default strategy to use for the given discriminator. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected VersionStrategy defaultStrategy(Version version)
      Determine the default strategy to use for the given version. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected VersionStrategy defaultStrategy(Version version, boolean adapting)
      Determine the default strategy to use for the given version. Does not take into account the current strategy, if any.
    • defaultStrategy

      protected VersionStrategy defaultStrategy(Version vers, FieldMapping vfield)
      Return the default version strategy, given a version field.
    • endConfiguration

      public void endConfiguration()
      Description copied from interface: Configurable
      Invoked upon completion of bean property configuration for this object.
      Specified by:
      endConfiguration in interface Configurable
      Overrides:
      endConfiguration in class MetaDataRepository
    • findBaseClassMapping

      protected ClassMapping findBaseClassMapping(ClassMapping mapping)
      Finds the base class mapping for the specified mapping. Loads all persistent types if necessary, since all persistent subclasses of this mapping may not have been resolved before this method is called.
    • setDefaultInheritanceStrategy

      protected void setDefaultInheritanceStrategy(ClassMapping mapping)
      If an inheritance strategy has not been set on this mapping, set it to the default (flat). This method should be called before strategies are created for the specified mapping.
    • hasInheritanceStrategy

      protected boolean hasInheritanceStrategy(ClassMapping mapping)
      Determines whether an inhertance strategy has been set on the specified mapping.