org.apache.openjpa.jdbc.meta
Class MappingRepository

java.lang.Object
  extended by org.apache.openjpa.meta.MetaDataRepository
      extended by org.apache.openjpa.jdbc.meta.MappingRepository
All Implemented Interfaces:
java.io.Serializable, org.apache.openjpa.enhance.PCRegistry.RegisterClassListener, org.apache.openjpa.lib.conf.Configurable, org.apache.openjpa.lib.util.Closeable, org.apache.openjpa.meta.MetaDataModes

public class MappingRepository
extends org.apache.openjpa.meta.MetaDataRepository

Repository of object/relational mapping information.

Author:
Abe White
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.openjpa.meta.MetaDataRepository
EMPTY_CLASSES, EMPTY_FIELDS, EMPTY_METAS, EMPTY_NON_PERSISTENT, EMPTY_ORDERS, EMPTY_XMLMETAS, VALIDATE_MAPPING, VALIDATE_META, VALIDATE_NONE, VALIDATE_RUNTIME, VALIDATE_UNENHANCED
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
 
Constructor Summary
MappingRepository()
          Default constructor.
 
Method Summary
 QueryResultMapping addQueryResultMapping(java.lang.Class cls, java.lang.String name)
          Add a query result mapping.
 void clear()
           
protected  ValueHandler defaultHandler(ValueMapping val)
          Determine the default handler to use for the given value.
protected  ValueHandler defaultHandler(ValueMapping val, boolean adapting)
          Determine the default handler to use for the given value.
protected  ClassStrategy defaultStrategy(ClassMapping cls)
          Determine the default strategy to use for the given class.
protected  ClassStrategy defaultStrategy(ClassMapping cls, boolean adapting)
          Determine the default strategy to use for the given class.
protected  DiscriminatorStrategy defaultStrategy(Discriminator discrim)
          Determine the default strategy to use for the given discriminator.
protected  DiscriminatorStrategy defaultStrategy(Discriminator discrim, boolean adapting)
          Determine the default strategy to use for the given discriminator.
protected  FieldStrategy defaultStrategy(FieldMapping field, boolean installHandlers)
          Determine the default strategy to use for the given field.
protected  FieldStrategy defaultStrategy(FieldMapping field, boolean installHandlers, boolean adapting)
          Determine the default strategy to use for the given field.
protected  VersionStrategy defaultStrategy(Version version)
          Determine the default strategy to use for the given version.
protected  VersionStrategy defaultStrategy(Version version, boolean adapting)
          Determine the default strategy to use for the given version.
protected  VersionStrategy defaultStrategy(Version vers, FieldMapping vfield)
          Return the default version strategy, given a version field.
protected  FieldStrategy defaultTypeStrategy(FieldMapping field, boolean installHandlers, boolean adapting)
          Return the built-in strategy for the field's type, or null if none.
 void endConfiguration()
           
 QueryResultMapping getCachedQueryResultMapping(java.lang.Class cls, java.lang.String name)
          Return the cached query result mapping with the given name, or null if none.
 DBDictionary getDBDictionary()
          Convenient access to dictionary for mappings.
 ClassMapping[] getImplementorMappings(java.lang.Class cls, java.lang.ClassLoader envLoader, boolean mustExist)
           
 ClassMapping getMapping(java.lang.Class cls, java.lang.ClassLoader envLoader, boolean mustExist)
           
 ClassMapping getMapping(java.lang.Object oid, java.lang.ClassLoader envLoader, boolean mustExist)
           
 MappingDefaults getMappingDefaults()
          Mapping defaults.
 ClassMapping[] getMappings()
           
 QueryResultMapping getQueryResultMapping(java.lang.Class cls, java.lang.String name, java.lang.ClassLoader envLoader, boolean mustExist)
          Return the query result mapping for the given name.
 QueryResultMapping[] getQueryResultMappings()
          Return all cached query result mappings.
 SchemaGroup getSchemaGroup()
          Representation of the database schema.
 StrategyInstaller getStrategyInstaller()
          Installs mapping strategies on components.
protected  FieldStrategy handlerCollectionStrategy(FieldMapping field, ValueHandler ehandler, boolean installHandlers)
          Return the collection strategy for the given element handler, or null if none.
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.
protected  ClassStrategy instantiateClassStrategy(java.lang.String name, ClassMapping cls)
          Return the strategy for the given name.
protected  DiscriminatorStrategy instantiateDiscriminatorStrategy(java.lang.String name, Discriminator discrim)
          Instantiate the given discriminator strategy.
protected  VersionStrategy instantiateVersionStrategy(java.lang.Class strat, Version version, java.lang.String props)
          Instantiate the given version strategy.
protected  VersionStrategy instantiateVersionStrategy(java.lang.String name, Version version)
          Instantiate the given version strategy.
protected  ValueHandler namedHandler(ValueMapping val)
          Instantiate the given value's named handler, or return null if no named handler.
protected  ClassStrategy namedStrategy(ClassMapping cls)
          Instantiate the given class' named strategy, or return null if no named strategy.
protected  DiscriminatorStrategy namedStrategy(Discriminator discrim)
          Instantiate the given discriminator's named strategy, or return null if no named strategy.
protected  FieldStrategy namedStrategy(FieldMapping field, boolean installHandlers)
          Instantiate the given field's named strategy, or return null if no named strategy.
protected  VersionStrategy namedStrategy(Version version)
          Instantiate the given version's named strategy, or return null if no named strategy.
protected  org.apache.openjpa.meta.ClassMetaData newClassMetaData(java.lang.Class type)
           
protected  org.apache.openjpa.meta.ClassMetaData[] newClassMetaDataArray(int length)
           
protected  Discriminator newDiscriminator(ClassMapping cls)
          Create discriminator metadata for the given class.
protected  org.apache.openjpa.meta.ClassMetaData newEmbeddedClassMetaData(org.apache.openjpa.meta.ValueMetaData owner)
           
protected  org.apache.openjpa.meta.FieldMetaData newFieldMetaData(java.lang.String name, java.lang.Class type, org.apache.openjpa.meta.ClassMetaData owner)
           
protected  org.apache.openjpa.meta.FieldMetaData[] newFieldMetaDataArray(int length)
           
protected  ClassMappingInfo newMappingInfo(ClassMapping cls)
          Create raw mapping info for the given instance.
protected  DiscriminatorMappingInfo newMappingInfo(Discriminator disc)
          Create raw mapping info for the given instance.
protected  FieldMappingInfo newMappingInfo(FieldMapping fm)
          Create raw mapping info for the given instance.
protected  ValueMappingInfo newMappingInfo(ValueMapping vm)
          Create raw mapping info for the given instance.
protected  VersionMappingInfo newMappingInfo(Version version)
          Create raw mapping info for the given instance.
protected  org.apache.openjpa.meta.Order[] newOrderArray(int size)
           
protected  org.apache.openjpa.meta.Order newRelatedFieldOrder(org.apache.openjpa.meta.FieldMetaData owner, org.apache.openjpa.meta.FieldMetaData rel, boolean asc)
           
protected  org.apache.openjpa.meta.SequenceMetaData newSequenceMetaData(java.lang.String name)
           
protected  org.apache.openjpa.meta.ValueMetaData newValueMetaData(org.apache.openjpa.meta.FieldMetaData owner)
           
protected  org.apache.openjpa.meta.Order newValueOrder(org.apache.openjpa.meta.FieldMetaData owner, boolean asc)
           
protected  Version newVersion(ClassMapping cls)
          Create version metadata for the given class.
protected  void prepareMapping(org.apache.openjpa.meta.ClassMetaData meta)
           
 boolean removeQueryResultMapping(java.lang.Class cls, java.lang.String name)
          Remove a query result mapping.
 boolean removeQueryResultMapping(QueryResultMapping res)
          Remove a query result mapping.
 void setMappingDefaults(MappingDefaults defaults)
          Mapping default.
 void setSchemaGroup(SchemaGroup schema)
          Representation of the database schema.
 void setStrategyInstaller(StrategyInstaller installer)
          Installs mapping strategies on components.
 
Methods inherited from class org.apache.openjpa.meta.MetaDataRepository
addMetaData, addMetaData, addNonMappedInterface, addPersistenceAware, addQueryMetaData, addSequenceMetaData, addSystemListener, addXMLMetaData, close, getCachedMetaData, getCachedQueryMetaData, getCachedSequenceMetaData, getCachedXMLMetaData, getConfiguration, getImplementorMetaDatas, getLog, getMetaData, getMetaData, getMetaData, getMetaDataFactory, getMetaDatas, getNonMappedInterface, getNonMappedInterfaces, getPersistenceAware, getPersistenceAwares, getPersistentTypeNames, getQueryKey, getQueryMetaData, getQueryMetaDatas, getResolve, getSequenceMetaData, getSequenceMetaDatas, getSourceMode, getSystemListeners, getValidate, getXMLMetaData, loadPersistentTypes, newOrder, newQueryMetaData, newXMLClassMetaData, newXMLClassMetaDataArray, newXMLFieldMetaData, register, removeMetaData, removeMetaData, removeNonMappedInterface, removePersistenceAware, removeQueryMetaData, removeQueryMetaData, removeSequenceMetaData, removeSequenceMetaData, removeSystemListener, setConfiguration, setMetaDataFactory, setResolve, setResolve, setSourceMode, setSourceMode, setValidate, setValidate, startConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappingRepository

public MappingRepository()
Default constructor. Configure via Configurable.

Method Detail

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(java.lang.Class cls,
                                                java.lang.String name,
                                                java.lang.ClassLoader envLoader,
                                                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(java.lang.Class cls,
                                                      java.lang.String name)
Return the cached query result mapping with the given name, or null if none.


addQueryResultMapping

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


removeQueryResultMapping

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


removeQueryResultMapping

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


getMapping

public ClassMapping getMapping(java.lang.Class cls,
                               java.lang.ClassLoader envLoader,
                               boolean mustExist)

getMappings

public ClassMapping[] getMappings()

getMapping

public ClassMapping getMapping(java.lang.Object oid,
                               java.lang.ClassLoader envLoader,
                               boolean mustExist)

getImplementorMappings

public ClassMapping[] getImplementorMappings(java.lang.Class cls,
                                             java.lang.ClassLoader envLoader,
                                             boolean mustExist)

clear

public void clear()
Overrides:
clear in class org.apache.openjpa.meta.MetaDataRepository

prepareMapping

protected void prepareMapping(org.apache.openjpa.meta.ClassMetaData meta)
Overrides:
prepareMapping in class org.apache.openjpa.meta.MetaDataRepository

newClassMetaData

protected org.apache.openjpa.meta.ClassMetaData newClassMetaData(java.lang.Class type)
Overrides:
newClassMetaData in class org.apache.openjpa.meta.MetaDataRepository

newClassMetaDataArray

protected org.apache.openjpa.meta.ClassMetaData[] newClassMetaDataArray(int length)
Overrides:
newClassMetaDataArray in class org.apache.openjpa.meta.MetaDataRepository

newFieldMetaData

protected org.apache.openjpa.meta.FieldMetaData newFieldMetaData(java.lang.String name,
                                                                 java.lang.Class type,
                                                                 org.apache.openjpa.meta.ClassMetaData owner)
Overrides:
newFieldMetaData in class org.apache.openjpa.meta.MetaDataRepository

newFieldMetaDataArray

protected org.apache.openjpa.meta.FieldMetaData[] newFieldMetaDataArray(int length)
Overrides:
newFieldMetaDataArray in class org.apache.openjpa.meta.MetaDataRepository

newEmbeddedClassMetaData

protected org.apache.openjpa.meta.ClassMetaData newEmbeddedClassMetaData(org.apache.openjpa.meta.ValueMetaData owner)
Overrides:
newEmbeddedClassMetaData in class org.apache.openjpa.meta.MetaDataRepository

newValueMetaData

protected org.apache.openjpa.meta.ValueMetaData newValueMetaData(org.apache.openjpa.meta.FieldMetaData owner)
Overrides:
newValueMetaData in class org.apache.openjpa.meta.MetaDataRepository

newSequenceMetaData

protected org.apache.openjpa.meta.SequenceMetaData newSequenceMetaData(java.lang.String name)
Overrides:
newSequenceMetaData in class org.apache.openjpa.meta.MetaDataRepository

newValueOrder

protected org.apache.openjpa.meta.Order newValueOrder(org.apache.openjpa.meta.FieldMetaData owner,
                                                      boolean asc)
Overrides:
newValueOrder in class org.apache.openjpa.meta.MetaDataRepository

newRelatedFieldOrder

protected org.apache.openjpa.meta.Order newRelatedFieldOrder(org.apache.openjpa.meta.FieldMetaData owner,
                                                             org.apache.openjpa.meta.FieldMetaData rel,
                                                             boolean asc)
Overrides:
newRelatedFieldOrder in class org.apache.openjpa.meta.MetaDataRepository

newOrderArray

protected org.apache.openjpa.meta.Order[] newOrderArray(int size)
Overrides:
newOrderArray in class org.apache.openjpa.meta.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(java.lang.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(java.lang.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(java.lang.String name,
                                                     Version version)
Instantiate the given version strategy.


instantiateVersionStrategy

protected VersionStrategy instantiateVersionStrategy(java.lang.Class strat,
                                                     Version version,
                                                     java.lang.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.


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()
Specified by:
endConfiguration in interface org.apache.openjpa.lib.conf.Configurable
Overrides:
endConfiguration in class org.apache.openjpa.meta.MetaDataRepository


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.