java.lang.Object
org.eclipse.persistence.descriptors.CMPPolicy
org.eclipse.persistence.internal.jpa.CMP3Policy
- All Implemented Interfaces:
- Serializable,- Cloneable
- Direct Known Subclasses:
- DynamicIdentityPolicy
Defines primary key extraction code for use in JPA. A descriptor should have a CMP3Policy
 attached to handle basic Id as well as IdClass/EmbeddedId usage.
- Since:
- TopLink 10.1.3
- See Also:
- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.persistence.descriptors.CMPPolicyCMPPolicy.KeyElementAccessor, CMPPolicy.KeyIsElementAccessor
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected HashMap<DatabaseField, CMPPolicy.KeyElementAccessor> Used to look up the KeyElementAccessor for a specific DatabaseField, used for resolving DerivedIdsprotected CMPPolicy.KeyElementAccessor[]Stores the fields for this classes compound primary key class if required.protected Class<?> protected StringFields inherited from class org.eclipse.persistence.descriptors.CMPPolicyAFTER_EJBCREATE, AFTER_EJBPOSTCREATE, ALL_MODIFICATIONS, descriptor, forceUpdate, mappedClass, modificationDeferralLevel, nonDeferredCreateTime, NONE, pessimisticLockingPolicy, UNDEFINED, UPDATE_MODIFICATIONS, updateAllFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddReadOnlyMappings(ClassDescriptor aDescriptor, DatabaseField field, List allMappings) INTERNAL: Add the writable mapping for the given field to the allMappings list.protected voidaddWritableMapping(ClassDescriptor aDescriptor, DatabaseField field, List allMappings) INTERNAL: Add the read only mappings for the given field to the allMappings list.clone()INTERNAL: Clone the CMP3PolicyvoidconvertClassNamesToClasses(ClassLoader classLoader) INTERNAL: Convert all the class-name-based settings in this object to actual class-based settings.createBeanUsingKey(Object key, AbstractSession session) INTERNAL: Use the key to create a bean and initialize its primary key fields.createPrimaryKeyFromId(Object key, AbstractSession session) INTERNAL: Use the key to create a EclipseLink primary key.protected FieldINTERNAL:protected CMPPolicy.KeyElementAccessor[]INTERNAL:<T> Class<T> INTERNAL: Return the java Class representing the primary key class nameINTERNAL:INTERNAL:getPkValueFromKeyForField(Object key, DatabaseField field, AbstractSession session) INTERNAL: Pull the value for the field from the key.voidinitialize(ClassDescriptor descriptor, AbstractSession session) INTERNAL: Initialize the CMPPolicy settings.protected CMPPolicy.KeyElementAccessor[]initializePrimaryKeyFields(Class<?> keyClass, AbstractSession session) INTERNAL: Cache the bean's primary key fields so speed up creating of primary key objects and initialization of beans.booleanINTERNAL: Return if this policy is for CMP3.voidremoteInitialize(ClassDescriptor descriptor, AbstractSession session) INTERNAL: Initialize the CMPPolicy settings for remote sessions.voidsetPKClass(Class<?> pkClass) ADVANCED:voidsetPrimaryKeyClassName(String pkClassName) INTERNAL:Methods inherited from class org.eclipse.persistence.descriptors.CMPPolicycreatePrimaryKeyInstance, createPrimaryKeyInstanceFromId, createPrimaryKeyInstanceFromPrimaryKeyValues, getClassInstance, getDeferModificationsUntilCommit, getDescriptor, getForceUpdate, getMappedClass, getNonDeferredCreateTime, getPessimisticLockingPolicy, getUpdateAllFields, hasPessimisticLockingPolicy, internalGetForceUpdate, internalGetUpdateAllFields, internalSetForceUpdate, internalSetUpdateAllFields, isSingleKey, setDeferModificationsUntilCommit, setDescriptor, setFieldValue, setForceUpdate, setMappedClass, setNonDeferredCreateTime, setPessimisticLockingPolicy, setUpdateAllFields
- 
Field Details- 
keyClassFieldsStores the fields for this classes compound primary key class if required.
- 
fieldToAccessorMapUsed to look up the KeyElementAccessor for a specific DatabaseField, used for resolving DerivedIds
- 
pkClassName
- 
pkClass
 
- 
- 
Constructor Details- 
CMP3Policypublic CMP3Policy()
 
- 
- 
Method Details- 
addWritableMappingprotected void addWritableMapping(ClassDescriptor aDescriptor, DatabaseField field, List allMappings) INTERNAL: Add the read only mappings for the given field to the allMappings list.
- 
addReadOnlyMappingsprotected void addReadOnlyMappings(ClassDescriptor aDescriptor, DatabaseField field, List allMappings) INTERNAL: Add the writable mapping for the given field to the allMappings list.
- 
cloneINTERNAL: Clone the CMP3Policy
- 
convertClassNamesToClassesINTERNAL: Convert all the class-name-based settings in this object to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.- Overrides:
- convertClassNamesToClassesin class- CMPPolicy
 
- 
isCMP3Policypublic boolean isCMP3Policy()INTERNAL: Return if this policy is for CMP3.- Overrides:
- isCMP3Policyin class- CMPPolicy
 
- 
setPrimaryKeyClassNameINTERNAL:
- 
getPKClassINTERNAL: Return the java Class representing the primary key class name- Overrides:
- getPKClassin class- CMPPolicy
 
- 
setPKClassADVANCED:
- 
getPKClassNameINTERNAL:
- 
getPKClassInstanceINTERNAL:- Overrides:
- getPKClassInstancein class- CMPPolicy
 
- 
createPrimaryKeyFromIdINTERNAL: Use the key to create a EclipseLink primary key. If the key is simple (direct mapped) then just add it to a vector, otherwise must go through the inefficient process of copying the key into the bean and extracting the key from the bean.- Overrides:
- createPrimaryKeyFromIdin class- CMPPolicy
 
- 
getFieldINTERNAL:- Returns:
- the field from the class with name equal to fieldName.
- Throws:
- NoSuchFieldException
 
- 
createBeanUsingKeyINTERNAL: Use the key to create a bean and initialize its primary key fields. Note: If is a compound PK then a primary key object is being used. This method should only be used for 'templates' when executing queries. The bean built will not be given an EntityContext and should not be used as an actual entity bean.- Overrides:
- createBeanUsingKeyin class- CMPPolicy
- Parameters:
- key- Object the primary key to use for initializing the bean's corresponding pk fields
- Returns:
- Object
 
- 
initializePrimaryKeyFieldsprotected CMPPolicy.KeyElementAccessor[] initializePrimaryKeyFields(Class<?> keyClass, AbstractSession session) INTERNAL: Cache the bean's primary key fields so speed up creating of primary key objects and initialization of beans. Note, we have to re-look up the fields for the bean class since these fields may have been loaded with the wrong loader (thank you Kirk). If the key is compound, we also have to look up the fields for the key.
- 
getKeyClassFieldsINTERNAL:- Overrides:
- getKeyClassFieldsin class- CMPPolicy
- Returns:
- Returns the keyClassFields.
 
- 
getPkValueFromKeyForFieldINTERNAL: Pull the value for the field from the key.- Parameters:
- key- Object the primary key to use to get the value for the field
- field- DatabaseField the field to find a value for
- Returns:
- Object
 
- 
initializepublic void initialize(ClassDescriptor descriptor, AbstractSession session) throws DescriptorException INTERNAL: Initialize the CMPPolicy settings.- Overrides:
- initializein class- CMPPolicy
- Throws:
- DescriptorException
 
- 
remoteInitializepublic void remoteInitialize(ClassDescriptor descriptor, AbstractSession session) throws DescriptorException INTERNAL: Initialize the CMPPolicy settings for remote sessions.- Overrides:
- remoteInitializein class- CMPPolicy
- Throws:
- DescriptorException
 
 
-