Class ClassMetaData
- All Implemented Interfaces:
Serializable
Lifecycle state
This object supports 3 lifecycle states. The first is the raw constructed object which represents pure MetaData (maybe from a MetaData file). The second is a "populated" object which represents MetaData for a Class with the metadata aligned to be appropriate for that Class. The third is "initialised" once the internal arrays are created. This object, once populated, will represent ALL fields in the class (including static, final and transient fields).Fields/Properties
This object keeps a list of FieldMetaData/PropertyMetaData objects for the fields of this class. In addition it has an array of FieldMetaData objects representing those that are actually managed by JDO ("managedFields"). This second set does not contain things like static, final or transient fields since JDO doesn't support those yet.Fields are of 2 types. The first are normal fields of this class. These have their own "relative" field number, relative to this class. The second type are "overriding" fields which override the baseline field in a superclass. These fields have no "relative" field number since they are relative to this class (and such a relative field number would make no sense). Fields are all added through addField() during the parse process, and are updated during the populate/initialise process to define their relative field numbers. Please refer to FieldMetaData for more details of fields.
Numbering of fields
Fields of the class are numbered in 2 ways. The first way is the numbering within a class. In a class, the field 'id's will start at 0. If a class is inherited, it will also have a second numbering for its fields - the "absolute" numbering. With "absolute" numbering, the fields start at the first field in the root superclass which has absolute number 0, and they are numbered from there, navigating down the hierarchy. In terms of what is stored in the records, the FieldMetaData stores fieldId as the first method (relative to the class it is in). The "absolute" numbering is always derived from this and the inheritance hierarchy.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List
<ImplementsMetaData> List of implements.protected boolean
Is the persistable class abstract.private static final long
Fields inherited from class org.datanucleus.metadata.AbstractClassMetaData
accessViaField, allMemberPositions, cacheable, catalog, createTimestampMemberPosition, createUserMemberPosition, datastoreIdentityMetaData, detachable, dfgMemberFlags, dfgMemberPositions, embeddedOnly, entityName, excludeDefaultListeners, excludeSuperClassListeners, fetchGroupMetaDataByName, fetchGroupMetaWithPostLoad, fetchGroups, foreignKeys, fullName, GENERATED_PK_SUFFIX, hasRelations, identitySpecified, identityType, implementationOfPersistentDefinition, indexes, inheritanceMetaData, initialising, instantiable, joins, listeners, managedMembers, mappedSuperclass, memberCount, memberPositionsByName, members, metaDataComplete, mmgr, multitenancyMetaData, name, nonPkMemberFlags, nonPkMemberPositions, noOfInheritedManagedMembers, objectidClass, overriddenMembers, pcSuperclassMetaData, persistableSuperclass, persistenceModifier, persistentInterfaceImplNeedingTableFromSubclass, persistentInterfaceImplNeedingTableFromSuperclass, pkIsDatastoreAttributed, pkMemberPositions, populating, primaryKeyMetaData, queries, queryResultMetaData, relationPositions, requiresExtent, schema, scoContainerMemberFlags, scoMutableMemberFlags, scoMutableMemberPositions, scoNonContainerMemberPositions, serializeRead, softDeleteMetaData, storedProcQueries, table, uniqueConstraints, unmappedColumns, updateTimestampMemberPosition, updateUserMemberPosition, usesSingleFieldIdentityClass, valueGenerationMemberPositions, versionMetaData
Fields inherited from class org.datanucleus.metadata.MetaData
EXTENSION_CLASS_CREATETIMESTAMP, EXTENSION_CLASS_CREATETIMESTAMP_COLUMN_NAME, EXTENSION_CLASS_CREATEUSER, EXTENSION_CLASS_CREATEUSER_COLUMN_LENGTH, EXTENSION_CLASS_CREATEUSER_COLUMN_NAME, EXTENSION_CLASS_MULTITENANCY_COLUMN_LENGTH, EXTENSION_CLASS_MULTITENANCY_COLUMN_NAME, EXTENSION_CLASS_MULTITENANCY_JDBC_TYPE, EXTENSION_CLASS_MULTITENANT, EXTENSION_CLASS_READ_ONLY, EXTENSION_CLASS_SOFTDELETE, EXTENSION_CLASS_SOFTDELETE_COLUMN_NAME, EXTENSION_CLASS_UPDATETIMESTAMP, EXTENSION_CLASS_UPDATETIMESTAMP_COLUMN_NAME, EXTENSION_CLASS_UPDATEUSER, EXTENSION_CLASS_UPDATEUSER_COLUMN_LENGTH, EXTENSION_CLASS_UPDATEUSER_COLUMN_NAME, EXTENSION_CLASS_VERSION_FIELD_NAME, EXTENSION_CLASS_VIEW_DEFINITION, EXTENSION_CLASS_VIEW_IMPORTS, EXTENSION_INDEX_COLUMN_ORDERING, EXTENSION_MEMBER_CACHEABLE, EXTENSION_MEMBER_CALENDAR_ONE_COLUMN, EXTENSION_MEMBER_CASCADE_ATTACH, EXTENSION_MEMBER_CASCADE_DETACH, EXTENSION_MEMBER_CASCADE_PERSIST, EXTENSION_MEMBER_CASCADE_REFRESH, EXTENSION_MEMBER_COMPARATOR_NAME, EXTENSION_MEMBER_CONTAINER_ALLOW_NULLS, EXTENSION_MEMBER_CREATE_TIMESTAMP, EXTENSION_MEMBER_CREATE_USER, EXTENSION_MEMBER_ENUM_VALUE_GETTER, EXTENSION_MEMBER_IMPLEMENTATION_CLASSES, EXTENSION_MEMBER_INSERTABLE, EXTENSION_MEMBER_KEY_IMPLEMENTATION_CLASSES, EXTENSION_MEMBER_LIST_ORDERING, EXTENSION_MEMBER_RELATION_DISCRIM_COLUMN, EXTENSION_MEMBER_RELATION_DISCRIM_PK, EXTENSION_MEMBER_RELATION_DISCRIM_VALUE, EXTENSION_MEMBER_STRATEGY_WHEN_NOTNULL, EXTENSION_MEMBER_TYPE_CONVERTER_DISABLED, EXTENSION_MEMBER_TYPE_CONVERTER_NAME, EXTENSION_MEMBER_UPDATE_TIMESTAMP, EXTENSION_MEMBER_UPDATE_USER, EXTENSION_MEMBER_UPDATEABLE, EXTENSION_MEMBER_VALUE_IMPLEMENTATION_CLASSES, EXTENSION_VERSION_NUMBER_INITIAL_VALUE, extensions, metaDataState, parent, VENDOR_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionClassMetaData
(ClassMetaData cmd, String implClassName) Constructor for creating the ClassMetaData for an implementation of a "persistent-abstract-class".ClassMetaData
(InterfaceMetaData imd, String implClassName, boolean copyFields) Constructor for creating the ClassMetaData for an implementation of a "persistent-interface".ClassMetaData
(PackageMetaData parent, String name) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addImplements
(ImplementsMetaData implmd) Method to add an implements to this class.protected void
Add MetaData of fields/properties not declared in MetaData.final List
<ImplementsMetaData> Accessor for the implements MetaDataprivate AbstractClassMetaData
Method to find a superinterface with MetaData that specifies NEW_TABLE inheritance strategyvoid
Method to initialise the object, creating internal convenience arrays.boolean
Whether the persistable class is abstract.private void
mergeMemberMetaDataForOverrideOfType
(Class type, AbstractMemberMetaData mmd, AbstractMemberMetaData overriddenMmd) Method to merge in an overridden member details into the overriding meta-data, updating the type.protected AbstractMemberMetaData
newDefaultedProperty
(String name) Utility to add a defaulted FieldMetaData to the class.void
populate
(ClassLoaderResolver clr, ClassLoader primary, MetaDataManager mgr) Method to provide the details of the class being represented by this MetaData.protected void
populateMemberMetaData
(ClassLoaderResolver clr, Class<?> cls, boolean pkMembers, ClassLoader primary) Populate MetaData for all members.toString()
Methods inherited from class org.datanucleus.metadata.AbstractClassMetaData
addFetchGroup, addForeignKey, addIndex, addJoin, addListener, addMember, addQuery, addQueryResultMetaData, addStoredProcQuery, addUniqueConstraint, addUnmappedColumn, applyDefaultDiscriminatorValueWhenNotSpecified, checkForCircularViewReferences, checkInitialised, checkNotYetPopulated, checkPopulated, determineIdentity, determineInheritanceMetaData, determineObjectIdClass, determineSuperClassName, excludeDefaultListeners, excludeSuperClassListeners, getAbsolutePositionOfMember, getAccessViaField, getAllMemberPositions, getBaseAbstractClassMetaData, getBaseDatastoreIdentityMetaData, getBaseInheritanceStrategy, getBasicMemberPositions, getBidirectionalRelationMemberPositions, getCatalog, getCreateTimestampMemberPosition, getCreateUserMemberPosition, getDatastoreIdentityMetaData, getDFGMemberFlags, getDFGMemberPositions, getDiscriminatorColumnMetaData, getDiscriminatorColumnName, getDiscriminatorMetaData, getDiscriminatorMetaDataForTable, getDiscriminatorMetaDataRoot, getDiscriminatorStrategy, getDiscriminatorStrategyForTable, getDiscriminatorValue, getEntityName, getFetchGroupMetaData, getFetchGroupMetaData, getFetchGroupMetaData, getForeignKeyMetaData, getFullClassName, getIdentityType, getIndexMetaData, getInheritanceMetaData, getJoinMetaData, getListenerForClass, getListeners, getManagedMembers, getMemberBeingOverridden, getMemberCount, getMetaDataForManagedMemberAtAbsolutePosition, getMetaDataForManagedMemberAtAbsolutePositionInternal, getMetaDataForManagedMemberAtRelativePosition, getMetaDataForMember, getMetaDataForMemberAtRelativePosition, getMetaDataManager, getMultitenancyMetaData, getMultivaluedMemberPositions, getName, getNonPKMemberFlags, getNonPKMemberPositions, getNonRelationMemberPositions, getNoOfInheritedManagedMembers, getNoOfManagedMembers, getNoOfMembers, getNoOfPrimaryKeyMembers, getNoOfQueries, getNoOfStoredProcQueries, getObjectidClass, getOverriddenMember, getOverriddenMembers, getPackageMetaData, getPackageName, getPersistableSuperclass, getPersistenceModifier, getPKMemberPositions, getPrimaryKeyMemberNames, getPrimaryKeyMetaData, getQueries, getQueryResultMetaData, getReferencedClassMetaData, getRelationMemberPositions, getRelativePositionOfMember, getRootInstantiableClass, getSchema, getSCOContainerMemberFlags, getSCOMutableMemberFlags, getSCOMutableMemberPositions, getSCONonContainerMemberPositions, getSoftDeleteMetaData, getStoredProcQueries, getSuperAbstractClassMetaData, getTable, getUniqueMetaData, getUnmappedColumns, getUpdateTimestampMemberPosition, getUpdateUserMemberPosition, getValueGenerationMemberPositions, getVersionMetaData, getVersionMetaDataForClass, getVersionMetaDataForTable, hasDiscriminatorStrategy, hasFetchGroupWithPostLoad, hasMember, hasRelations, inheritIdentity, initialiseMemberPositionInformation, isCacheable, isDescendantOf, isDetachable, isEmbeddedOnly, isExcludeDefaultListeners, isExcludeSuperClassListeners, isImplementationOfPersistentDefinition, isInstantiable, isMappedSuperclass, isMetaDataComplete, isRequiresExtent, isRootInstantiableClass, isSameOrAncestorOf, isSerializeRead, isSoftDelete, isVersioned, loadClass, newDatastoreIdentityMetaData, newFetchGroupMetaData, newFieldMetaData, newForeignKeyMetaData, newIndexMetaData, newInheritanceMetaData, newJoinMetaData, newMultitenancyMetaData, newPrimaryKeyMetaData, newPropertyMetaData, newQueryMetaData, newSoftDeleteMetaData, newStoredProcQueryMetaData, newUniqueMetaData, newUnmappedColumnMetaData, newVersionMetaData, pkIsDatastoreAttributed, setAccessViaField, setCacheable, setCacheable, setCatalog, setDatastoreIdentityMetaData, setDetachable, setDetachable, setEmbeddedOnly, setEmbeddedOnly, setEntityName, setIdentityType, setInheritanceMetaData, setMappedSuperclass, setMetaDataComplete, setMultitenancyMetaData, setObjectIdClass, setPersistenceModifier, setPrimaryKeyMetaData, setRequiresExtent, setRequiresExtent, setSchema, setSerializeRead, setSoftDeleteMetaData, setTable, setVersionMetaData, usesSingleFieldIdentityClass, validateObjectIdClass, validateUnmappedColumns, validateUserInputForIdentity, validateUserInputForInheritanceMetaData
Methods inherited from class org.datanucleus.metadata.MetaData
addExtension, addExtensions, getExtensions, getNoOfExtensions, getParent, getValueForExtension, getValuesForExtension, hasExtension, isInitialised, isPopulated, isUsed, removeExtension, setExtensions, setInitialised, setParent, setPopulated, setUsed
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
implementations
List of implements. -
isAbstract
protected boolean isAbstractIs the persistable class abstract.
-
-
Constructor Details
-
ClassMetaData
Constructor. Takes the basic string information found in the MetaData file.- Parameters:
parent
- The package to which this class belongsname
- Name of class
-
ClassMetaData
Constructor for creating the ClassMetaData for an implementation of a "persistent-interface".- Parameters:
imd
- MetaData for the "persistent-interface"implClassName
- Name of the implementation classcopyFields
- Whether to copy the fields of the interface too
-
ClassMetaData
Constructor for creating the ClassMetaData for an implementation of a "persistent-abstract-class".- Parameters:
cmd
- MetaData for the implementation of the "persistent-abstract-class"implClassName
- Name of the implementation class
-
-
Method Details
-
populate
Method to provide the details of the class being represented by this MetaData. This can be used to firstly provide defaults for attributes that aren't specified in the MetaData, and secondly to report any errors with attributes that have been specified that are inconsistent with the class being represented.One possible use of this method would be to take a basic ClassMetaData for a class and call this, passing in the users class. This would then add AbstractMemberMetaData for all fields in this class providing defaults for all of these.
- Specified by:
populate
in classAbstractClassMetaData
- Parameters:
clr
- ClassLoaderResolver to use in loading any classesprimary
- the primary ClassLoader to use (or null)mgr
- MetaData manager
-
getMetaDataForSuperinterfaceManagingTable
private AbstractClassMetaData getMetaDataForSuperinterfaceManagingTable(Class cls, ClassLoaderResolver clr) Method to find a superinterface with MetaData that specifies NEW_TABLE inheritance strategy- Parameters:
cls
- The classclr
- ClassLoader resolver- Returns:
- The AbstractClassMetaData for the class managing the table
-
addMetaDataForMembersNotInMetaData
Add MetaData of fields/properties not declared in MetaData. Note that if a member is defined using some generic type in the superclass and this class can use a TypeVariable to resolve it then this will add the member to "members" here since the type will be different to this class.- Parameters:
cls
- Class represented by this metadata
-
mergeMemberMetaDataForOverrideOfType
private void mergeMemberMetaDataForOverrideOfType(Class type, AbstractMemberMetaData mmd, AbstractMemberMetaData overriddenMmd) Method to merge in an overridden member details into the overriding meta-data, updating the type. If the overriddenMmd is null then simply updates the type on the mmd.- Parameters:
type
- The type to usemmd
- The overriding member meta-dataoverriddenMmd
- The (base) overridden meta-data
-
populateMemberMetaData
protected void populateMemberMetaData(ClassLoaderResolver clr, Class<?> cls, boolean pkMembers, ClassLoader primary) Populate MetaData for all members.- Parameters:
clr
- The ClassLoaderResolvercls
- This classpkMembers
- Process pk fields/properties (or non-PK if false)primary
- the primary ClassLoader to use (or null)- Throws:
InvalidMetaDataException
- if the Class for a declared type in a field cannot be loaded by theclr
InvalidMetaDataException
- if a field declared in the MetaData does not exist in the Class
-
initialise
Method to initialise the object, creating internal convenience arrays. Initialises all sub-objects. populate() should be called BEFORE calling this.- Overrides:
initialise
in classMetaData
- Parameters:
clr
- ClassLoader resolver
-
isAbstract
public boolean isAbstract()Whether the persistable class is abstract.- Returns:
- true if the persistable class is abstract
-
newDefaultedProperty
Utility to add a defaulted FieldMetaData to the class. Provided as a method since then any derived classes can override it (e.g ClassMetaData can create a FieldMetaData)- Overrides:
newDefaultedProperty
in classAbstractClassMetaData
- Parameters:
name
- name of field- Returns:
- the new FieldMetaData
-
getImplementsMetaData
Accessor for the implements MetaData- Returns:
- Returns the implements MetaData.
-
addImplements
Method to add an implements to this class.- Parameters:
implmd
- Meta-Data for the implements
-
toString
-