org.apache.openjpa.meta
Class ClassMetaData

java.lang.Object
  extended by org.apache.openjpa.meta.Extensions
      extended by org.apache.openjpa.meta.ClassMetaData
All Implemented Interfaces:
Serializable, Comparable<ClassMetaData>, ValueListener, SourceTracker, Commentable, MetaDataContext, MetaDataModes
Direct Known Subclasses:
ClassMapping

public class ClassMetaData
extends Extensions
implements Comparable<ClassMetaData>, SourceTracker, MetaDataContext, MetaDataModes, Commentable, ValueListener

Contains metadata about a persistent type. This metadata is available both at enhancement time and runtime. Note that this class employs aggressive caching, and therefore it is important to finalize the configuration of field metadatas before invoking methods that depend on that configuration, such as getPrimaryKeyFields().

Author:
Abe White
See Also:
Serialized Form

Field Summary
static int ACCESS_EXPLICIT
          Persistent class has explicitly defined an access type.
static int ACCESS_FIELD
          Persistent attributes are accessed via direct field access.
static int ACCESS_PROPERTY
          Persistent attributes are accessed via setters and getters.
static int ACCESS_UNKNOWN
          Unknown access type.
protected static String DEFAULT_STRING
           
static int ID_APPLICATION
          Application identity type.
static int ID_DATASTORE
          Datastore identity type.
static int ID_UNKNOWN
          Unknown identity type.
static String SYNTHETIC
          Value for using a synthetic detached state field, which is the default.
 
Fields inherited from class org.apache.openjpa.meta.Extensions
OPENJPA
 
Fields inherited from interface org.apache.openjpa.lib.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
 
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
 
Fields inherited from interface org.apache.openjpa.lib.xml.Commentable
EMPTY_COMMENTS
 
Constructor Summary
protected ClassMetaData(Class<?> type, MetaDataRepository repos)
          Constructor.
protected ClassMetaData(ValueMetaData owner)
          Embedded constructor.
 
Method Summary
 FetchGroup addDeclaredFetchGroup(String name)
          Adds fetch group of the given name, or returns existing instance.
 FieldMetaData addDeclaredField(String name, Class<?> type)
          Add a new field metadata to this class.
 void addDeclaredInterface(Class<?> iface)
          Explicitly declare the given interface among the ones this class implements.
 FieldMetaData addDefinedSuperclassField(String name, Class<?> type, Class<?> sup)
          Add a new defined superclass field metadata to this class.
protected  void addExtensionKeys(Collection exts)
          Add all the known extension keys to the specified collection; any implementation that utilized new extensions should override this method to include both the known extensions of its superclass as well as its own extension keys.
protected  void clearAllFieldCache()
          Clear cached field data.
protected  void clearDefinedFieldCache()
          Clear defined field data.
(package private)  void clearExtraFieldDataTable()
          Clear impl data and intermediate data table.
protected  void clearFieldCache()
          Clear cached field data.
protected  void clearSubclassCache()
          Clear cached subclass data.
 int compareTo(ClassMetaData other)
           
 void copy(ClassMetaData meta)
          Copy the metadata from the given instance to this one.
 void defineSuperclassFields(boolean force)
          Incorporate superclass fields redefined in this subclass into this metadata.
 boolean equals(Object other)
           
 int getAccessType()
          The access type used by this class.
 Boolean getCacheEnabled()
          Returns tri-state status on whether this class has been enabled for caching.
 int getColNumber()
          Return the column number in the line of the file at which this instance was parsed.
 String[] getComments()
          Return comments, or empty array if none.
 FetchGroup[] getCustomFetchGroups()
          Return all fetch groups for this type, including superclass groups.
 DataCache getDataCache()
          Return the data cache for this class, or null if it is not cachable.
 boolean getDataCacheEnabled()
          Affirms true if this receiver is annotated with @DataCache and is not disabled.
 String getDataCacheName()
          The name of the data cache that stores the managed instance of this class, by default.
 int getDataCacheTimeout()
          The cache timeout for this class.
 FetchGroup[] getDeclaredFetchGroups()
          Return the fetch groups declared explicitly in this type.
 FieldMetaData getDeclaredField(int index)
          Return the metadata for the persistent or transactional field with the given relative index.
 FieldMetaData getDeclaredField(String name)
          Return the metadata for the persistent or transactional field with the given name, without including superclass fields.
 String[] getDeclaredFieldNames()
          Utility method to get names of all declared fields excluding the superclasses' sorted in lexical order.
 FieldMetaData[] getDeclaredFields()
          Return only the fields for this class, without superclass fields.
 Class<?>[] getDeclaredInterfaces()
          Return all explicitly declared interfaces this class implements.
 FieldMetaData[] getDeclaredUnmanagedFields()
          Return any fields that were added as non-managed.
 FieldMetaData[] getDefaultFetchGroupFields()
          Return the list of fields in the default fetch group, including superclass fields, or an empty array if none.
 FieldMetaData[] getDefinedFields()
          Returns an array of all the fields defined by this class.
 FieldMetaData[] getDefinedFieldsInListingOrder()
          Returns all fields defined by this class in the order they are listed in the metadata file.
 FieldMetaData getDefinedSuperclassField(String name)
          Return the defined superclass field with the given name, or null if none.
 Class<?> getDescribedType()
          The persistence capable class described by this metadata.
 String getDescribedTypeString()
          The persistence capable stringified class described by this metadata.
 String getDetachedState()
          The name of the detach state field, or null if none.
 Field getDetachedStateField()
          Return the detach state field, or null if none.
 ValueMetaData getEmbeddingMetaData()
          If this metadata is for an embedded object, returning the owning value.
 ClassLoader getEnvClassLoader()
          The environmental loader used when loading this metadata.
 int getExtraFieldDataIndex(int field)
          Return the intermediate field data index of the given field in the compacted array, or -1 if the field does not use extra data.
 int getExtraFieldDataLength()
          Return the number of fields that use impl or intermediate data, in order to create a compacted array for storage of said data.
 FetchGroup getFetchGroup(String name)
          Gets a named fetch group.
 FieldMetaData getField(int index)
          Return the metadata for the persistent or transactional field with the given absolute index.
 FieldMetaData getField(String name)
          Return the metadata for the persistent or transactional field with the given name.
 String[] getFieldNames()
          Utility method to get names of all fields including the superclasses' sorted in lexical order.
 FieldMetaData[] getFields()
          Return all field metadata, including superclass fields.
 FieldMetaData[] getFieldsInListingOrder()
          Returns all fields in the order they are listed in the metadata file.
 SequenceMetaData getIdentitySequenceMetaData()
          Metadata for the datastore identity sequence.
 String getIdentitySequenceName()
          The datastore identity sequence name, or null for none.
 int getIdentityStrategy()
          The strategy to use for datastore identity generation.
 int getIdentityType()
          The type of identity being used.
 String[] getInterfaceAliasedProperties(Class<?> iface)
          Return all aliases property named for the given interface.
 Class<?> getInterfaceImpl()
          Return the managed interface implementor if any.
 String getInterfacePropertyAlias(Class<?> iface, String orig)
          Get local field alias for the given interface property.
 LifecycleMetaData getLifecycleMetaData()
          Information about lifecycle callbacks for this class.
 int getLineNumber()
          Return the line number of the file at which this instance was parsed.
 int getListingIndex()
          The index in which this class was listed in the metadata.
 FieldMetaData[] getLrsFields()
          Return all large result set fields.
 ClassMetaData[] getMappedPCSubclassMetaDatas()
          Return all mapped subclasses.
 ClassMetaData getMappedPCSuperclassMetaData()
          Return the closest mapped superclass.
 Class<?> getObjectIdType()
          The metadata-specified class to use for the object ID.
 Class<?>[] getPCSubclasses()
          Return the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.
 ClassMetaData[] getPCSubclassMetaDatas()
          Return the metadata for the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.
 Class<?> getPCSuperclass()
          The persistence capable superclass of the described type.
 ClassMetaData getPCSuperclassMetaData()
          The metadata for this class' superclass.
 FieldMetaData[] getPrimaryKeyFields()
          Return primary key fields, or empty array if none.
 FieldMetaData[] getProxyFields()
          Return all fields that are types that need to be wrappered by a proxy.
 MetaDataRepository getRepository()
          Return the owning repository.
 boolean getRequiresExtent()
          Whether the type requires extent management.
 int getResolve()
          The resolve mode for this metadata.
 String getResourceName()
          Return the domain-meaningful name of the resource that was loaded from this source.
 File getSourceFile()
          Return the file from which this instance was parsed.
 int getSourceMode()
          The source mode this metadata has been loaded under.
 Object getSourceScope()
          Return the domain-dependent scope of this instance within its file.
 int getSourceType()
          Return the type of source.
protected  FieldMetaData getSuperclassField(FieldMetaData supField)
          Return the superclass copy of the given field.
 String getTypeAlias()
          Returns the alias for the described type, or null if none has been set.
 FieldMetaData getVersionField()
          Return the version field for this class, if any.
 boolean hasAbstractPKField()
          Convenience method to determine if the pcType modeled by this ClassMetaData object is both abstract and declares PKFields.
 int hashCode()
           
 boolean hasPKFieldsFromAbstractClass()
          Convenience method to determine if this type is a direct decendent of an abstract type declaring PKFields.
protected  void initializeMapping()
          Initialize mapping.
 boolean isAbstract()
           
 boolean isAccessibleField(String field)
          Return whether the given name represents a managed or static field of this class, including superclass fields.
 boolean isDetachable()
          Whether instances are detachable.
 boolean isEmbeddable()
           
 boolean isEmbeddedOnly()
          Whether the type can only be used as an embedded object.
 boolean isExplicitAccess()
          Affirms if access style is explicitly defined.
 boolean isIntercepting()
          Whether the type's fields are actively intercepted, either by redefinition or enhancement.
 boolean isManagedInterface()
          Whether the type is a managed interface.
 boolean isMapped()
          Whether this class is mapped to the datastore.
 boolean isMixedAccess()
          Affirms if attributes of this class use mixed access types.
 boolean isObjectIdTypeShared()
          Whether this type uses an application identity class that is shared with other classes, and is therefore wrapped in an ObjectId.
 boolean isOpenJPAIdentity()
          Whether this type uses OpenJPA identity.
(package private)  void mergeFieldAccess(FieldMetaData fmd, int fCode)
          Asserts the the given field (which must belong to this receiver) can be set to the given access code.
 void registerForValueUpdate(String... values)
           
 boolean removeDeclaredFetchGroup(FetchGroup fg)
          Remove a declared fetch group.
 boolean removeDeclaredField(FieldMetaData field)
          Remove the given field from management.
 boolean removeDeclaredInterface(Class<?> iface)
          Remove the given interface from the declared list.
 boolean removeDefinedSuperclassField(FieldMetaData field)
          Remove the given field from management.
 boolean resolve(int mode)
          Resolve and validate metadata.
protected  void resolveMapping(boolean runtime)
          Resolve mapping data.
protected  void resolveMeta(boolean runtime)
          Resolve metadata.
 void setAbstract(boolean flag)
           
 void setAccessType(int type)
          Sets the access type.
 void setCacheEnabled(boolean enabled)
          Sets the eligibility status of this class for cache.
 void setColNumber(int colNum)
           
 void setComments(String[] comments)
          Set comments.
 void setDataCacheName(String name)
          Set the cache name for this class.
 void setDataCacheTimeout(int timeout)
          The cache timeout for this class.
protected  void setDescribedType(Class<?> type)
          Set the class described by this metadata.
 void setDetachable(boolean detachable)
          Whether instances are detachable.
 void setDetachedState(String field)
          The name of the detach state field, or null if none.
 void setEmbeddable()
           
 void setEmbeddedOnly(boolean embed)
          Whether the type can only be used as an embedded object.
 void setEnvClassLoader(ClassLoader loader)
          The class environmental loader used when loading this metadata.
 void setIdentitySequenceName(String seqName)
          The datastore identity sequence name, or null for none.
 void setIdentityStrategy(int strategy)
          The strategy to use for datastore identity generation.
 void setIdentityType(int type)
          The type of identity being used.
 void setIntercepting(boolean intercepting)
          Whether the type's fields are actively intercepted, either by redefinition or enhancement.
 void setInterfaceImpl(Class<?> impl)
          Set the managed interface implementor class.
 void setInterfacePropertyAlias(Class<?> iface, String orig, String local)
          Alias properties from the given interface during queries to the local field.
 void setLineNumber(int lineNum)
           
 void setListingIndex(int index)
          The index in which this field was listed in the metadata.
 void setManagedInterface(boolean managedInterface)
          Whether the type is a managed interface
 void setObjectIdType(Class<?> cls, boolean shared)
          The metadata-specified class to use for the object ID.
 void setPCSuperclass(Class<?> pc)
          The persistence capable superclass of the described type.
 void setPCSuperclassMetaData(ClassMetaData meta)
          The metadata for this class' superclass.
 void setRequiresExtent(boolean req)
          Whether the type requires extent management.
 void setResolve(int mode)
          The resolve mode for this metadata.
 void setResolve(int mode, boolean on)
          The resolve mode for this metadata.
 void setSource(File file, int srcType)
           
 void setSourceMode(int mode)
          The source mode this metadata has been loaded under.
 void setSourceMode(int mode, boolean on)
          The source mode this metadata has been loaded under.
 void setTypeAlias(String alias)
          Sets the alias for the described type.
(package private)  String[] toNames(FieldMetaData[] fields)
           
 String toString()
           
 boolean useIdClassFromParent()
          Return true if this class uses IdClass derived from idClass of the parent entity which annotated as id in the child class.
 Boolean usesDetachedState()
          Whether an instance of this type has detached state.
protected  void validateMapping(boolean runtime)
          Validate mapping data.
protected  void validateMeta(boolean runtime)
          Validate resolved metadata.
 void valueChanged(Value val)
          Callback used by Value objects to notify listener of change.
 
Methods inherited from class org.apache.openjpa.meta.Extensions
addExtension, addExtension, copy, getBooleanExtension, getBooleanExtension, getDoubleExtension, getDoubleExtension, getEmbeddedExtensions, getEmbeddedExtensions, getExtensionKeys, getExtensionKeys, getExtensionVendors, getIntExtension, getIntExtension, getObjectExtension, getObjectExtension, getStringExtension, getStringExtension, hasExtension, hasExtension, isEmpty, removeEmbeddedExtensions, removeEmbeddedExtensions, removeExtension, removeExtension, validateDataStoreExtensionPrefix, validateExtensionKeys
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ID_UNKNOWN

public static final int ID_UNKNOWN
Unknown identity type.

See Also:
Constant Field Values

ID_DATASTORE

public static final int ID_DATASTORE
Datastore identity type.

See Also:
Constant Field Values

ID_APPLICATION

public static final int ID_APPLICATION
Application identity type.

See Also:
Constant Field Values

ACCESS_UNKNOWN

public static final int ACCESS_UNKNOWN
Unknown access type.


ACCESS_FIELD

public static final int ACCESS_FIELD
Persistent attributes are accessed via direct field access. Bit flag.


ACCESS_PROPERTY

public static final int ACCESS_PROPERTY
Persistent attributes are accessed via setters and getters. Bit flag.


ACCESS_EXPLICIT

public static final int ACCESS_EXPLICIT
Persistent class has explicitly defined an access type. This will allow the attributes to use mixed access i.e. some field may use ACCESS_FIELD while others ACCESS_PROPERTY.


SYNTHETIC

public static final String SYNTHETIC
Value for using a synthetic detached state field, which is the default.

See Also:
Constant Field Values

DEFAULT_STRING

protected static final String DEFAULT_STRING
See Also:
Constant Field Values
Constructor Detail

ClassMetaData

protected ClassMetaData(Class<?> type,
                        MetaDataRepository repos)
Constructor. Supply described type and repository.


ClassMetaData

protected ClassMetaData(ValueMetaData owner)
Embedded constructor. Supply embedding value.

Method Detail

getRepository

public MetaDataRepository getRepository()
Return the owning repository.

Specified by:
getRepository in interface MetaDataContext
Specified by:
getRepository in class Extensions

getEmbeddingMetaData

public ValueMetaData getEmbeddingMetaData()
If this metadata is for an embedded object, returning the owning value.


getDescribedType

public Class<?> getDescribedType()
The persistence capable class described by this metadata.


getDescribedTypeString

public String getDescribedTypeString()
The persistence capable stringified class described by this metadata.


setDescribedType

protected void setDescribedType(Class<?> type)
Set the class described by this metadata. The type may be reset when an embedded value changes its declared type.


getEnvClassLoader

public ClassLoader getEnvClassLoader()
The environmental loader used when loading this metadata. The class metadata should use this loader when loading metadata for its superclass and field types.


setEnvClassLoader

public void setEnvClassLoader(ClassLoader loader)
The class environmental loader used when loading this metadata. The class metadata should use this loader when loading metadata for its superclass and field types.


getPCSuperclass

public Class<?> getPCSuperclass()
The persistence capable superclass of the described type.


setPCSuperclass

public void setPCSuperclass(Class<?> pc)
The persistence capable superclass of the described type.


getPCSuperclassMetaData

public ClassMetaData getPCSuperclassMetaData()
The metadata for this class' superclass.


setPCSuperclassMetaData

public void setPCSuperclassMetaData(ClassMetaData meta)
The metadata for this class' superclass.


isMapped

public boolean isMapped()
Whether this class is mapped to the datastore. By default, only returns false if class is embedded-only, but subclasses might override to allow unmapped other types.


getMappedPCSuperclassMetaData

public ClassMetaData getMappedPCSuperclassMetaData()
Return the closest mapped superclass.


getPCSubclasses

public Class<?>[] getPCSubclasses()
Return the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.


getPCSubclassMetaDatas

public ClassMetaData[] getPCSubclassMetaDatas()
Return the metadata for the known persistence capable subclasses of the described type, or empty array if none or if this is embedded metadata.


getMappedPCSubclassMetaDatas

public ClassMetaData[] getMappedPCSubclassMetaDatas()
Return all mapped subclasses.


getIdentityType

public int getIdentityType()
The type of identity being used. This will be one of: If unspecified, defaults to ID_DATASTORE if there are no primary key fields, and ID_APPLICATION otherwise.


setIdentityType

public void setIdentityType(int type)
The type of identity being used. This will be one of: If unspecified, defaults to ID_DATASTORE if there are no primary key fields, and ID_APPLICATION otherwise.


getObjectIdType

public Class<?> getObjectIdType()
The metadata-specified class to use for the object ID.


setObjectIdType

public void setObjectIdType(Class<?> cls,
                            boolean shared)
The metadata-specified class to use for the object ID. When there is IdClass annotation, AnnotationMetaDataParser will call this method to set ObjectId type. However, if this is a derived identity in the child entity where a relation field (parent entity) is used as an id, and this relation field has an IdClass, the IdClass annotation in the child entity can be ignored as Openjpa will automatically wrap parent's IdClass as child's IdClass.


isObjectIdTypeShared

public boolean isObjectIdTypeShared()
Whether this type uses an application identity class that is shared with other classes, and is therefore wrapped in an ObjectId.


isOpenJPAIdentity

public boolean isOpenJPAIdentity()
Whether this type uses OpenJPA identity.


getIdentityStrategy

public int getIdentityStrategy()
The strategy to use for datastore identity generation. One of the constants from ValueStrategies.


setIdentityStrategy

public void setIdentityStrategy(int strategy)
The strategy to use for datastore identity generation. One of the constants from ValueStrategies.


getIdentitySequenceName

public String getIdentitySequenceName()
The datastore identity sequence name, or null for none.


setIdentitySequenceName

public void setIdentitySequenceName(String seqName)
The datastore identity sequence name, or null for none.


getIdentitySequenceMetaData

public SequenceMetaData getIdentitySequenceMetaData()
Metadata for the datastore identity sequence.


getLifecycleMetaData

public LifecycleMetaData getLifecycleMetaData()
Information about lifecycle callbacks for this class.


getTypeAlias

public String getTypeAlias()
Returns the alias for the described type, or null if none has been set.

See Also:
setTypeAlias(java.lang.String)

setTypeAlias

public void setTypeAlias(String alias)
Sets the alias for the described type. The alias can be any arbitrary string that the implementation can later use to refer to the class. Note that at runtime, only the alias computed when the persistent type was enhanced is used.

Parameters:
alias - the alias name to apply to the described type

getAccessType

public int getAccessType()
The access type used by this class.


setAccessType

public void setAccessType(int type)
Sets the access type.


mergeFieldAccess

void mergeFieldAccess(FieldMetaData fmd,
                      int fCode)
Asserts the the given field (which must belong to this receiver) can be set to the given access code. If the field code is allowed, it may have the side-effect of changing the access code of this receiver.


isExplicitAccess

public boolean isExplicitAccess()
Affirms if access style is explicitly defined.


isMixedAccess

public boolean isMixedAccess()
Affirms if attributes of this class use mixed access types.


getRequiresExtent

public boolean getRequiresExtent()
Whether the type requires extent management.


setRequiresExtent

public void setRequiresExtent(boolean req)
Whether the type requires extent management.


isEmbeddedOnly

public boolean isEmbeddedOnly()
Whether the type can only be used as an embedded object.


setEmbeddedOnly

public void setEmbeddedOnly(boolean embed)
Whether the type can only be used as an embedded object.


isEmbeddable

public boolean isEmbeddable()

setEmbeddable

public void setEmbeddable()

isIntercepting

public boolean isIntercepting()
Whether the type's fields are actively intercepted, either by redefinition or enhancement.


setIntercepting

public void setIntercepting(boolean intercepting)
Whether the type's fields are actively intercepted, either by redefinition or enhancement.


isManagedInterface

public boolean isManagedInterface()
Whether the type is a managed interface.


setManagedInterface

public void setManagedInterface(boolean managedInterface)
Whether the type is a managed interface


getInterfaceImpl

public Class<?> getInterfaceImpl()
Return the managed interface implementor if any.


setInterfaceImpl

public void setInterfaceImpl(Class<?> impl)
Set the managed interface implementor class.


getDeclaredInterfaces

public Class<?>[] getDeclaredInterfaces()
Return all explicitly declared interfaces this class implements.


addDeclaredInterface

public void addDeclaredInterface(Class<?> iface)
Explicitly declare the given interface among the ones this class implements.


removeDeclaredInterface

public boolean removeDeclaredInterface(Class<?> iface)
Remove the given interface from the declared list.


setInterfacePropertyAlias

public void setInterfacePropertyAlias(Class<?> iface,
                                      String orig,
                                      String local)
Alias properties from the given interface during queries to the local field.


getInterfacePropertyAlias

public String getInterfacePropertyAlias(Class<?> iface,
                                        String orig)
Get local field alias for the given interface property.


getInterfaceAliasedProperties

public String[] getInterfaceAliasedProperties(Class<?> iface)
Return all aliases property named for the given interface.


getExtraFieldDataLength

public int getExtraFieldDataLength()
Return the number of fields that use impl or intermediate data, in order to create a compacted array for storage of said data.


getExtraFieldDataIndex

public int getExtraFieldDataIndex(int field)
Return the intermediate field data index of the given field in the compacted array, or -1 if the field does not use extra data.

See Also:
getExtraFieldDataLength()

isAccessibleField

public boolean isAccessibleField(String field)
Return whether the given name represents a managed or static field of this class, including superclass fields.


getProxyFields

public FieldMetaData[] getProxyFields()
Return all fields that are types that need to be wrappered by a proxy. The types that need to be proxied are:

  • org.apache.openjpa.meta.JavaTypes.CALENDAR
  • org.apache.openjpa.meta.JavaTypes.COLLECTION
  • org.apache.openjpa.meta.JavaTypes.DATE
  • org.apache.openjpa.meta.JavaTypes.MAP
  • org.apache.openjpa.meta.JavaTypes.OBJECT


  • getLrsFields

    public FieldMetaData[] getLrsFields()
    Return all large result set fields. Will never return null.


    getFields

    public FieldMetaData[] getFields()
    Return all field metadata, including superclass fields.


    getSuperclassField

    protected FieldMetaData getSuperclassField(FieldMetaData supField)
    Return the superclass copy of the given field.


    getDeclaredFields

    public FieldMetaData[] getDeclaredFields()
    Return only the fields for this class, without superclass fields.


    getPrimaryKeyFields

    public FieldMetaData[] getPrimaryKeyFields()
    Return primary key fields, or empty array if none. The order in which the keys are returned will be the order in which the fields are declared, starting at the least-derived superclass and ending with the primary key fields of the most-derived subclass.


    getDefaultFetchGroupFields

    public FieldMetaData[] getDefaultFetchGroupFields()
    Return the list of fields in the default fetch group, including superclass fields, or an empty array if none.


    getVersionField

    public FieldMetaData getVersionField()
    Return the version field for this class, if any.


    getField

    public FieldMetaData getField(int index)
    Return the metadata for the persistent or transactional field with the given absolute index.

    Returns:
    the field's metadata, or null if not found

    getDeclaredField

    public FieldMetaData getDeclaredField(int index)
    Return the metadata for the persistent or transactional field with the given relative index.

    Returns:
    the field's metadata, or null if not found

    getField

    public FieldMetaData getField(String name)
    Return the metadata for the persistent or transactional field with the given name.

    Returns:
    the field's metadata, or null if not found

    getDeclaredField

    public FieldMetaData getDeclaredField(String name)
    Return the metadata for the persistent or transactional field with the given name, without including superclass fields.

    Returns:
    the field's metadata, or null if not found

    getDeclaredUnmanagedFields

    public FieldMetaData[] getDeclaredUnmanagedFields()
    Return any fields that were added as non-managed. All other methods to get fields return only those that are managed.


    addDeclaredField

    public FieldMetaData addDeclaredField(String name,
                                          Class<?> type)
    Add a new field metadata to this class.


    removeDeclaredField

    public boolean removeDeclaredField(FieldMetaData field)
    Remove the given field from management.

    Returns:
    true if the field was removed, false otherwise

    getDefinedSuperclassField

    public FieldMetaData getDefinedSuperclassField(String name)
    Return the defined superclass field with the given name, or null if none.


    addDefinedSuperclassField

    public FieldMetaData addDefinedSuperclassField(String name,
                                                   Class<?> type,
                                                   Class<?> sup)
    Add a new defined superclass field metadata to this class.


    removeDefinedSuperclassField

    public boolean removeDefinedSuperclassField(FieldMetaData field)
    Remove the given field from management.

    Returns:
    true if the field was removed, false otherwise

    defineSuperclassFields

    public void defineSuperclassFields(boolean force)
    Incorporate superclass fields redefined in this subclass into this metadata. This method is generally called after metadata is resolved and mapping information is loaded, but before mapping resolve.

    Parameters:
    force - whether to force re-mapping of even mapped superclass fields

    getDefinedFields

    public FieldMetaData[] getDefinedFields()
    Returns an array of all the fields defined by this class. This includes mapped declared fields and any concrete mapping of unmapped superclass fields performed by this class.


    getFieldsInListingOrder

    public FieldMetaData[] getFieldsInListingOrder()
    Returns all fields in the order they are listed in the metadata file. Unlisted fields are placed after listed ones.


    getDefinedFieldsInListingOrder

    public FieldMetaData[] getDefinedFieldsInListingOrder()
    Returns all fields defined by this class in the order they are listed in the metadata file. Unlisted fields are placed after listed ones. This array includes declared transactional and unmanaged fields.


    getDataCacheName

    public String getDataCacheName()
    The name of the data cache that stores the managed instance of this class, by default. This can be overwritten by per-instance basis cache distribution policy.

    Returns:
    null if this class is disabled from cache by @DataCache(enabled=false). default if @DataCache(enabled=true) without a name. Otherwise, data cache name set by the user via @DataCache name attribute.

    setDataCacheName

    public void setDataCacheName(String name)
    Set the cache name for this class.

    Parameters:
    can - be null to disable cache.

    getDataCacheEnabled

    public boolean getDataCacheEnabled()
    Affirms true if this receiver is annotated with @DataCache and is not disabled. A separate state variable is necessary besides the name of the cache defaulted to a special string.


    getDataCacheTimeout

    public int getDataCacheTimeout()
    The cache timeout for this class. -1 indicates no timeout.


    setDataCacheTimeout

    public void setDataCacheTimeout(int timeout)
    The cache timeout for this class. -1 indicates no timeout.


    getDataCache

    public DataCache getDataCache()
    Return the data cache for this class, or null if it is not cachable.


    isDetachable

    public boolean isDetachable()
    Whether instances are detachable.


    setDetachable

    public void setDetachable(boolean detachable)
    Whether instances are detachable.


    getDetachedState

    public String getDetachedState()
    The name of the detach state field, or null if none.


    setDetachedState

    public void setDetachedState(String field)
    The name of the detach state field, or null if none.


    getDetachedStateField

    public Field getDetachedStateField()
    Return the detach state field, or null if none.


    usesDetachedState

    public Boolean usesDetachedState()
    Whether an instance of this type has detached state.

    Returns:
    true if a detached instance must have detached state, false if it does not, and null if it may use a manually-constructed instance without detached state

    clearAllFieldCache

    protected void clearAllFieldCache()
    Clear cached field data.


    clearDefinedFieldCache

    protected void clearDefinedFieldCache()
    Clear defined field data.


    clearFieldCache

    protected void clearFieldCache()
    Clear cached field data.


    clearSubclassCache

    protected void clearSubclassCache()
    Clear cached subclass data.


    clearExtraFieldDataTable

    void clearExtraFieldDataTable()
    Clear impl data and intermediate data table.


    hashCode

    public int hashCode()
    Overrides:
    hashCode in class Object

    equals

    public boolean equals(Object other)
    Overrides:
    equals in class Object

    compareTo

    public int compareTo(ClassMetaData other)
    Specified by:
    compareTo in interface Comparable<ClassMetaData>

    toString

    public String toString()
    Overrides:
    toString in class Object

    getResolve

    public int getResolve()
    The resolve mode for this metadata.


    setResolve

    public void setResolve(int mode)
    The resolve mode for this metadata.


    setResolve

    public void setResolve(int mode,
                           boolean on)
    The resolve mode for this metadata.


    resolve

    public boolean resolve(int mode)
    Resolve and validate metadata. Return true if already resolved.


    resolveMeta

    protected void resolveMeta(boolean runtime)
    Resolve metadata.


    validateMeta

    protected void validateMeta(boolean runtime)
    Validate resolved metadata.


    resolveMapping

    protected void resolveMapping(boolean runtime)
    Resolve mapping data. Logs resolve message and resolves super by default.


    validateMapping

    protected void validateMapping(boolean runtime)
    Validate mapping data.


    initializeMapping

    protected void initializeMapping()
    Initialize mapping. Logs init message by default.


    useIdClassFromParent

    public boolean useIdClassFromParent()
    Return true if this class uses IdClass derived from idClass of the parent entity which annotated as id in the child class. In this case, there are no key fields in the child entity corresponding to the fields in the IdClass.


    getDeclaredFetchGroups

    public FetchGroup[] getDeclaredFetchGroups()
    Return the fetch groups declared explicitly in this type.


    getCustomFetchGroups

    public FetchGroup[] getCustomFetchGroups()
    Return all fetch groups for this type, including superclass groups.


    getFetchGroup

    public FetchGroup getFetchGroup(String name)
    Gets a named fetch group. If not available in this receiver then looks up the inheritance hierarchy.

    Parameters:
    name - name of a fetch group.
    Returns:
    an existing fetch group of the given name if known to this receiver or any of its superclasses. Otherwise null.

    addDeclaredFetchGroup

    public FetchGroup addDeclaredFetchGroup(String name)
    Adds fetch group of the given name, or returns existing instance.

    Parameters:
    name - a non-null, non-empty name. Must be unique within this receiver's scope. The super class may have a group with the same name.

    removeDeclaredFetchGroup

    public boolean removeDeclaredFetchGroup(FetchGroup fg)
    Remove a declared fetch group.


    getSourceFile

    public File getSourceFile()
    Description copied from interface: SourceTracker
    Return the file from which this instance was parsed.

    Specified by:
    getSourceFile in interface SourceTracker

    getSourceScope

    public Object getSourceScope()
    Description copied from interface: SourceTracker
    Return the domain-dependent scope of this instance within its file.

    Specified by:
    getSourceScope in interface SourceTracker

    getSourceType

    public int getSourceType()
    Description copied from interface: SourceTracker
    Return the type of source.

    Specified by:
    getSourceType in interface SourceTracker

    setSource

    public void setSource(File file,
                          int srcType)

    getResourceName

    public String getResourceName()
    Description copied from interface: SourceTracker
    Return the domain-meaningful name of the resource that was loaded from this source. I.e., if we had loaded the source for a Java class, this would return the name of the class.

    Specified by:
    getResourceName in interface SourceTracker

    getLineNumber

    public int getLineNumber()
    Description copied from interface: SourceTracker
    Return the line number of the file at which this instance was parsed.

    Specified by:
    getLineNumber in interface SourceTracker

    setLineNumber

    public void setLineNumber(int lineNum)

    getColNumber

    public int getColNumber()
    Description copied from interface: SourceTracker
    Return the column number in the line of the file at which this instance was parsed.

    Specified by:
    getColNumber in interface SourceTracker

    setColNumber

    public void setColNumber(int colNum)

    getSourceMode

    public int getSourceMode()
    The source mode this metadata has been loaded under.


    setSourceMode

    public void setSourceMode(int mode)
    The source mode this metadata has been loaded under.


    setSourceMode

    public void setSourceMode(int mode,
                              boolean on)
    The source mode this metadata has been loaded under.


    getListingIndex

    public int getListingIndex()
    The index in which this class was listed in the metadata. Defaults to -1 if this class was not listed in the metadata.


    setListingIndex

    public void setListingIndex(int index)
    The index in which this field was listed in the metadata. Defaults to -1 if this class was not listed in the metadata.


    getComments

    public String[] getComments()
    Description copied from interface: Commentable
    Return comments, or empty array if none.

    Specified by:
    getComments in interface Commentable

    setComments

    public void setComments(String[] comments)
    Description copied from interface: Commentable
    Set comments.

    Specified by:
    setComments in interface Commentable

    copy

    public void copy(ClassMetaData meta)
    Copy the metadata from the given instance to this one. Do not copy mapping information.


    addExtensionKeys

    protected void addExtensionKeys(Collection exts)
    Description copied from class: Extensions
    Add all the known extension keys to the specified collection; any implementation that utilized new extensions should override this method to include both the known extensions of its superclass as well as its own extension keys.

    Overrides:
    addExtensionKeys in class Extensions

    registerForValueUpdate

    public void registerForValueUpdate(String... values)

    valueChanged

    public void valueChanged(Value val)
    Description copied from interface: ValueListener
    Callback used by Value objects to notify listener of change.

    Specified by:
    valueChanged in interface ValueListener

    getFieldNames

    public String[] getFieldNames()
    Utility method to get names of all fields including the superclasses' sorted in lexical order.


    getDeclaredFieldNames

    public String[] getDeclaredFieldNames()
    Utility method to get names of all declared fields excluding the superclasses' sorted in lexical order.


    toNames

    String[] toNames(FieldMetaData[] fields)

    isAbstract

    public boolean isAbstract()

    setAbstract

    public void setAbstract(boolean flag)

    hasAbstractPKField

    public boolean hasAbstractPKField()
    Convenience method to determine if the pcType modeled by this ClassMetaData object is both abstract and declares PKFields. This method is used by the PCEnhancer to determine if special handling is required.

    Returns:

    hasPKFieldsFromAbstractClass

    public boolean hasPKFieldsFromAbstractClass()
    Convenience method to determine if this type is a direct decendent of an abstract type declaring PKFields. Returns true if there are no pcTypes mapped to a table between this type and an abstract pcType declaring PKFields. Returns false if there no such abstract pcTypes in the inheritance hierarchy or if there are any pcTypes mapped to tables in between the type represented by this ClassMetaData object and the abstract pcType declaring PKFields.

    Returns:

    setCacheEnabled

    public void setCacheEnabled(boolean enabled)
    Sets the eligibility status of this class for cache.


    getCacheEnabled

    public Boolean getCacheEnabled()
    Returns tri-state status on whether this class has been enabled for caching.

    Returns:
    TRUE or FALSE denote this class has been explicitly enabled or disabled for caching. If no status has been explicitly set, then the status of the persistent super class, if any, is returned.


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