Package org.apache.openjpa.meta
Class ClassMetaData
- java.lang.Object
-
- org.apache.openjpa.meta.Extensions
-
- org.apache.openjpa.meta.ClassMetaData
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<ClassMetaData>
,ValueListener
,SourceTracker
,Commentable
,MetaDataContext
,MetaDataModes
- Direct Known Subclasses:
ClassMapping
public class ClassMetaData extends Extensions implements java.lang.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 asgetPrimaryKeyFields()
.- Author:
- Abe White
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description 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 java.lang.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 java.lang.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.xml.Commentable
EMPTY_COMMENTS
-
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.meta.SourceTracker
SRC_ANNOTATIONS, SRC_OTHER, SRC_XML
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ClassMetaData(java.lang.Class<?> type, MetaDataRepository repos)
Constructor.protected
ClassMetaData(ValueMetaData owner)
Embedded constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FetchGroup
addDeclaredFetchGroup(java.lang.String name)
Adds fetch group of the given name, or returns existing instance.FieldMetaData
addDeclaredField(java.lang.String name, java.lang.Class<?> type)
Add a new field metadata to this class.void
addDeclaredInterface(java.lang.Class<?> iface)
Explicitly declare the given interface among the ones this class implements.FieldMetaData
addDefinedSuperclassField(java.lang.String name, java.lang.Class<?> type, java.lang.Class<?> sup)
Add a new defined superclass field metadata to this class.protected void
addExtensionKeys(java.util.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.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(java.lang.Object other)
int
getAccessType()
The access type used by this class.java.lang.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.java.lang.String[]
getComments()
Return comments, or empty array if none.FetchGroup[]
getCustomFetchGroups()
Return all fetch groups for this type, including superclass groups but excluding the standard groups such as "default" or "all".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.java.lang.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. -1 indicates no timeout.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(java.lang.String name)
Return the metadata for the persistent or transactional field with the given name, without including superclass fields.java.lang.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.java.lang.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(java.lang.String name)
Return the defined superclass field with the given name, or null if none.java.lang.Class<?>
getDescribedType()
The persistence capable class described by this metadata.java.lang.String
getDescribedTypeString()
The persistence capable stringified class described by this metadata.java.lang.String
getDetachedState()
The name of the detach state field, or null if none.java.lang.reflect.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.java.lang.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(java.lang.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(java.lang.String name)
Return the metadata for the persistent or transactional field with the given name.java.lang.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.java.lang.Class<?>
getIdClass()
The class specified with the @IdClass annotation if usedSequenceMetaData
getIdentitySequenceMetaData()
Metadata for the datastore identity sequence.java.lang.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.java.lang.String[]
getInterfaceAliasedProperties(java.lang.Class<?> iface)
Return all aliases property named for the given interface.java.lang.Class<?>
getInterfaceImpl()
Return the managed interface implementor if any.java.lang.String
getInterfacePropertyAlias(java.lang.Class<?> iface, java.lang.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.java.util.List<FieldMetaData>
getMappyedByIdFields()
java.lang.Class<?>
getObjectIdType()
The metadata-specified class to use for the object ID.java.lang.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.java.lang.Class<?>
getPCSuperclass()
The persistence capable superclass of the described type.ClassMetaData
getPCSuperclassMetaData()
The metadata for this class' superclass.int[]
getPkAndNonPersistentManagedFmdIndexes()
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.java.lang.String
getResourceName()
Return the domain-meaningful name of the resource that was loaded from this source.java.io.File
getSourceFile()
Return the file from which this instance was parsed.int
getSourceMode()
The source mode this metadata has been loaded under.java.lang.String
getSourceName()
java.lang.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.java.lang.String
getTypeAlias()
Returns the alias for the described type, ornull
if none has been set.boolean
getUseSchemaElement()
Set whether to include schema name in generated class filesFieldMetaData
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
hasInverseManagedFields()
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(java.lang.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 anObjectId
.boolean
isOpenJPAIdentity()
Whether this type uses OpenJPA identity.void
registerForValueUpdate(java.lang.String... values)
boolean
removeDeclaredFetchGroup(FetchGroup fg)
Remove a declared fetch group.boolean
removeDeclaredField(FieldMetaData field)
Remove the given field from management.boolean
removeDeclaredInterface(java.lang.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(java.lang.String[] comments)
Set comments.void
setDataCacheName(java.lang.String name)
Set the cache name for this class.void
setDataCacheTimeout(int timeout)
The cache timeout for this class. -1 indicates no timeout.protected void
setDescribedType(java.lang.Class<?> type)
Set the class described by this metadata.void
setDetachable(boolean detachable)
Whether instances are detachable.void
setDetachedState(java.lang.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(java.lang.ClassLoader loader)
The class environmental loader used when loading this metadata.void
setIdentitySequenceName(java.lang.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(java.lang.Class<?> impl)
Set the managed interface implementor class.void
setInterfacePropertyAlias(java.lang.Class<?> iface, java.lang.String orig, java.lang.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 interfacevoid
setObjectIdType(java.lang.Class<?> cls, boolean shared)
The metadata-specified class to use for the object ID.void
setPCSuperclass(java.lang.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(java.io.File file, int srcType, java.lang.String srcName)
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(java.lang.String alias)
Sets the alias for the described type.void
setUseSchemaElement(boolean useSchemaElement)
Get whether to include schema name in generated class filesjava.lang.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.java.lang.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 byValue
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
-
-
-
-
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 java.lang.String SYNTHETIC
Value for using a synthetic detached state field, which is the default.- See Also:
- Constant Field Values
-
DEFAULT_STRING
protected static final java.lang.String DEFAULT_STRING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ClassMetaData
protected ClassMetaData(java.lang.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 interfaceMetaDataContext
- Specified by:
getRepository
in classExtensions
-
getEmbeddingMetaData
public ValueMetaData getEmbeddingMetaData()
If this metadata is for an embedded object, returning the owning value.
-
getDescribedType
public java.lang.Class<?> getDescribedType()
The persistence capable class described by this metadata.
-
getDescribedTypeString
public java.lang.String getDescribedTypeString()
The persistence capable stringified class described by this metadata.
-
setDescribedType
protected void setDescribedType(java.lang.Class<?> type)
Set the class described by this metadata. The type may be reset when an embedded value changes its declared type.
-
getEnvClassLoader
public java.lang.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(java.lang.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 java.lang.Class<?> getPCSuperclass()
The persistence capable superclass of the described type.
-
setPCSuperclass
public void setPCSuperclass(java.lang.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 java.lang.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:ID_UNKNOWN
: unknown identity typeID_DATASTORE
: identity managed by the data store and independent of the fields of the instanceID_APPLICATION
: identity managed by the application and defined by one or more fields of the instance
ID_DATASTORE
if there are no primary key fields, andID_APPLICATION
otherwise.
-
setIdentityType
public void setIdentityType(int type)
The type of identity being used. This will be one of:ID_UNKNOWN
: unknown identity typeID_DATASTORE
: identity managed by the data store and independent of the fields of the instanceID_APPLICATION
: identity managed by the application and defined by one or more fields of the instance
ID_DATASTORE
if there are no primary key fields, andID_APPLICATION
otherwise.
-
getObjectIdType
public java.lang.Class<?> getObjectIdType()
The metadata-specified class to use for the object ID.
-
setObjectIdType
public void setObjectIdType(java.lang.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 anObjectId
.
-
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 fromValueStrategies
.
-
setIdentityStrategy
public void setIdentityStrategy(int strategy)
The strategy to use for datastore identity generation. One of the constants fromValueStrategies
.
-
getIdentitySequenceName
public java.lang.String getIdentitySequenceName()
The datastore identity sequence name, or null for none.
-
setIdentitySequenceName
public void setIdentitySequenceName(java.lang.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 java.lang.String getTypeAlias()
Returns the alias for the described type, ornull
if none has been set.- See Also:
setTypeAlias(java.lang.String)
-
setTypeAlias
public void setTypeAlias(java.lang.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.
-
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 java.lang.Class<?> getInterfaceImpl()
Return the managed interface implementor if any.
-
setInterfaceImpl
public void setInterfaceImpl(java.lang.Class<?> impl)
Set the managed interface implementor class.
-
getDeclaredInterfaces
public java.lang.Class<?>[] getDeclaredInterfaces()
Return all explicitly declared interfaces this class implements.
-
addDeclaredInterface
public void addDeclaredInterface(java.lang.Class<?> iface)
Explicitly declare the given interface among the ones this class implements.
-
removeDeclaredInterface
public boolean removeDeclaredInterface(java.lang.Class<?> iface)
Remove the given interface from the declared list.
-
setInterfacePropertyAlias
public void setInterfacePropertyAlias(java.lang.Class<?> iface, java.lang.String orig, java.lang.String local)
Alias properties from the given interface during queries to the local field.
-
getInterfacePropertyAlias
public java.lang.String getInterfacePropertyAlias(java.lang.Class<?> iface, java.lang.String orig)
Get local field alias for the given interface property.
-
getInterfaceAliasedProperties
public java.lang.String[] getInterfaceAliasedProperties(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String name, java.lang.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(java.lang.String name)
Return the defined superclass field with the given name, or null if none.
-
addDefinedSuperclassField
public FieldMetaData addDefinedSuperclassField(java.lang.String name, java.lang.Class<?> type, java.lang.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 java.lang.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(java.lang.String name)
Set the cache name for this class.- Parameters:
name
- can benull
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 java.lang.String getDetachedState()
The name of the detach state field, or null if none.
-
setDetachedState
public void setDetachedState(java.lang.String field)
The name of the detach state field, or null if none.
-
getDetachedStateField
public java.lang.reflect.Field getDetachedStateField()
Return the detach state field, or null if none.
-
usesDetachedState
public java.lang.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.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(ClassMetaData other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ClassMetaData>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.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 but excluding the standard groups such as "default" or "all".
-
getFetchGroup
public FetchGroup getFetchGroup(java.lang.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(java.lang.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 java.io.File getSourceFile()
Description copied from interface:SourceTracker
Return the file from which this instance was parsed.- Specified by:
getSourceFile
in interfaceSourceTracker
-
getSourceScope
public java.lang.Object getSourceScope()
Description copied from interface:SourceTracker
Return the domain-dependent scope of this instance within its file.- Specified by:
getSourceScope
in interfaceSourceTracker
-
getSourceType
public int getSourceType()
Description copied from interface:SourceTracker
Return the type of source.- Specified by:
getSourceType
in interfaceSourceTracker
-
setSource
public void setSource(java.io.File file, int srcType, java.lang.String srcName)
-
getResourceName
public java.lang.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 interfaceSourceTracker
-
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 interfaceSourceTracker
-
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 interfaceSourceTracker
-
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 java.lang.String[] getComments()
Description copied from interface:Commentable
Return comments, or empty array if none.- Specified by:
getComments
in interfaceCommentable
-
setComments
public void setComments(java.lang.String[] comments)
Description copied from interface:Commentable
Set comments.- Specified by:
setComments
in interfaceCommentable
-
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(java.util.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 classExtensions
-
registerForValueUpdate
public void registerForValueUpdate(java.lang.String... values)
-
valueChanged
public void valueChanged(Value val)
Description copied from interface:ValueListener
Callback used byValue
objects to notify listener of change.- Specified by:
valueChanged
in interfaceValueListener
-
getFieldNames
public java.lang.String[] getFieldNames()
Utility method to get names of all fields including the superclasses' sorted in lexical order.
-
getDeclaredFieldNames
public java.lang.String[] getDeclaredFieldNames()
Utility method to get names of all declared fields excluding the superclasses' sorted in lexical order.
-
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.
-
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.
-
setCacheEnabled
public void setCacheEnabled(boolean enabled)
Sets the eligibility status of this class for cache.
-
getCacheEnabled
public java.lang.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.
-
getSourceName
public java.lang.String getSourceName()
-
getPkAndNonPersistentManagedFmdIndexes
public int[] getPkAndNonPersistentManagedFmdIndexes()
-
hasInverseManagedFields
public boolean hasInverseManagedFields()
-
getMappyedByIdFields
public java.util.List<FieldMetaData> getMappyedByIdFields()
-
getUseSchemaElement
public boolean getUseSchemaElement()
Set whether to include schema name in generated class files
-
setUseSchemaElement
public void setUseSchemaElement(boolean useSchemaElement)
Get whether to include schema name in generated class files
-
getIdClass
public java.lang.Class<?> getIdClass()
The class specified with the @IdClass annotation if used
-
-