Class CMPPolicy
java.lang.Object
org.eclipse.persistence.descriptors.CMPPolicy
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
org.eclipse.persistence.internal.jpa.CMP3Policy
Description: Place holder for CMP specific information. This class can be set on the ClassDescriptor.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
INTERNAL: This is the interface used to encapsulate the the type of key class elementprotected static final class
INTERNAL: This class will be used when the keyClass is a primitive -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
issue SQL after ejbCreate but before ejbPostCreatestatic final int
issue SQL after ejbPostCreatestatic final int
defer all modifications, inserts and deletes included (default)protected ClassDescriptor
protected Boolean
protected Class
Class originally mapped, before anything was generated.protected int
The object deferral level.protected int
This setting will allow customers to control when Toplink will issue the insert SQL for CMP beans.static final int
defer no changesprotected PessimisticLockingPolicy
Allow the bean to always be locked as it enters a new transaction.static final int
undefined if it is non-deferred issue sql at createstatic final int
defer updatesprotected Boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
INTERNAL: Clone the CMPPolicyvoid
convertClassNamesToClasses
(ClassLoader classLoader) INTERNAL: Convert all the class-name-based settings in this object to actual class-based settings.createBeanUsingKey
(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Use the key to create a bean and initialize its primary key fields.createPrimaryKeyFromId
(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Use the key to create a EclipseLink primary key.createPrimaryKeyInstance
(Object object, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Create an instance of the Id class or value from the object.createPrimaryKeyInstanceFromId
(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Create an instance of the composite primary key class for the key object.createPrimaryKeyInstanceFromPrimaryKeyValues
(org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, Object... keyElements) INTERNAL: Create an instance of the composite primary key class for the key object.getClassInstance
(Class<?> cls) INTERNAL: Return a new instance of the class provided.int
ADVANCED: This can be used to control when changes to objects are submitted to the database This is only applicable to TopLink's CMP implementation and not available within the core.INTERNAL:boolean
ADVANCED: Return true if descriptor is set to always update all registered objects of this typeprotected CMPPolicy.KeyElementAccessor[]
INTERNAL:PUBLIC: Answer the mapped class.int
ADVANCED: This setting is only available for CMP beans that are not being deferred.PUBLIC: Return the policy for bean pessimistic lockingINTERNAL:INTERNAL:boolean
ADVANCED: Return true if descriptor is set to update all fields for an object of this type when an update occurs.boolean
PUBLIC: Return true if bean pessimistic locking is configuredvoid
initialize
(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize the CMPPolicy settings.INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.void
internalSetForceUpdate
(Boolean newForceUpdateValue) INTERNAL: internal method to set the tri-state value.void
internalSetUpdateAllFields
(Boolean newUpdateAllFieldsValue) INTERNAL: internal method to set the tri-state value.boolean
INTERNAL: Return if this policy is for CMP3.protected boolean
isSingleKey
(CMPPolicy.KeyElementAccessor[] pkElementArray) Check to see if there is a single key element.void
remoteInitialize
(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Initialize the CMPPolicy settings for remote sessions.void
setDeferModificationsUntilCommit
(int deferralLevel) ADVANCED: This can be set to control when changes to objects are submitted to the database This is only applicable to TopLink's CMP implementation and not available within the core.void
setDescriptor
(ClassDescriptor owningDescriptor) INTERNAL:protected void
setFieldValue
(CMPPolicy.KeyElementAccessor accessor, Object keyInstance, DatabaseMapping mapping, org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, Object... keyElements) INTERNAL: Recursive method to set a field value in the given key instance.void
setForceUpdate
(boolean shouldForceUpdate) ADVANCED: Configure whether TopLink should always update all registered objects of this type.void
setMappedClass
(Class newMappedClass) PUBLIC: Define the mapped class.void
setNonDeferredCreateTime
(int createTime) ADVANCED: This setting is only available for CMP beans that are not being deferred.void
PUBLIC: Configure bean pessimistic lockingvoid
setUpdateAllFields
(boolean shouldUpdatAllFields) ADVANCED: Configure whether TopLink should update all fields for an object of this type when an update occurs.
-
Field Details
-
forceUpdate
-
updateAllFields
-
pessimisticLockingPolicy
Allow the bean to always be locked as it enters a new transaction. -
mappedClass
Class originally mapped, before anything was generated. -
descriptor
-
modificationDeferralLevel
protected int modificationDeferralLevelThe object deferral level. This controls when objects changes will be sent to the Database. -
NONE
public static final int NONEdefer no changes- See Also:
-
UPDATE_MODIFICATIONS
public static final int UPDATE_MODIFICATIONSdefer updates- See Also:
-
ALL_MODIFICATIONS
public static final int ALL_MODIFICATIONSdefer all modifications, inserts and deletes included (default)- See Also:
-
nonDeferredCreateTime
protected int nonDeferredCreateTimeThis setting will allow customers to control when Toplink will issue the insert SQL for CMP beans. -
UNDEFINED
public static final int UNDEFINEDundefined if it is non-deferred issue sql at create- See Also:
-
AFTER_EJBCREATE
public static final int AFTER_EJBCREATEissue SQL after ejbCreate but before ejbPostCreate- See Also:
-
AFTER_EJBPOSTCREATE
public static final int AFTER_EJBPOSTCREATEissue SQL after ejbPostCreate- See Also:
-
-
Constructor Details
-
CMPPolicy
public CMPPolicy()
-
-
Method Details
-
getNonDeferredCreateTime
public int getNonDeferredCreateTime()ADVANCED: This setting is only available for CMP beans that are not being deferred. Using it will allow TopLink to determine if the INSERT SQL should be sent to the database before or after the postCreate call. -
getPessimisticLockingPolicy
PUBLIC: Return the policy for bean pessimistic locking- See Also:
-
setDeferModificationsUntilCommit
public void setDeferModificationsUntilCommit(int deferralLevel) ADVANCED: This can be set to control when changes to objects are submitted to the database This is only applicable to TopLink's CMP implementation and not available within the core. -
setMappedClass
PUBLIC: Define the mapped class. This is the class which was originally mapped in the MW- Parameters:
newMappedClass
-
-
getMappedClass
PUBLIC: Answer the mapped class. This is the class which was originally mapped in the MW -
setNonDeferredCreateTime
public void setNonDeferredCreateTime(int createTime) ADVANCED: This setting is only available for CMP beans that are not being deferred. Using it will allow TopLink to determine if the INSERT SQL should be sent to the database before or after the postCreate call. -
setPessimisticLockingPolicy
PUBLIC: Configure bean pessimistic locking- Parameters:
policy
-- See Also:
-
hasPessimisticLockingPolicy
public boolean hasPessimisticLockingPolicy()PUBLIC: Return true if bean pessimistic locking is configured -
getDeferModificationsUntilCommit
public int getDeferModificationsUntilCommit()ADVANCED: This can be used to control when changes to objects are submitted to the database This is only applicable to TopLink's CMP implementation and not available within the core. -
getForceUpdate
public boolean getForceUpdate()ADVANCED: Return true if descriptor is set to always update all registered objects of this type -
setForceUpdate
public void setForceUpdate(boolean shouldForceUpdate) ADVANCED: Configure whether TopLink should always update all registered objects of this type. NOTE: if set to true, then updateAllFields must also be set to true- Parameters:
shouldForceUpdate
-
-
getUpdateAllFields
public boolean getUpdateAllFields()ADVANCED: Return true if descriptor is set to update all fields for an object of this type when an update occurs. -
setUpdateAllFields
public void setUpdateAllFields(boolean shouldUpdatAllFields) ADVANCED: Configure whether TopLink should update all fields for an object of this type when an update occurs.- Parameters:
shouldUpdatAllFields
-
-
internalGetForceUpdate
INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time. -
internalGetUpdateAllFields
INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time. -
internalSetForceUpdate
INTERNAL: internal method to set the tri-state value. This is done in InheritancePolicy at init time. -
internalSetUpdateAllFields
INTERNAL: internal method to set the tri-state value. This is done in InheritancePolicy at init time. -
initialize
public void initialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException INTERNAL: Initialize the CMPPolicy settings.- Throws:
DescriptorException
-
remoteInitialize
public void remoteInitialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException INTERNAL: Initialize the CMPPolicy settings for remote sessions.- Throws:
DescriptorException
-
getDescriptor
INTERNAL:- Returns:
- Returns the owningDescriptor.
-
setDescriptor
INTERNAL:- Parameters:
owningDescriptor
- The owningDescriptor to set.
-
setFieldValue
protected void setFieldValue(CMPPolicy.KeyElementAccessor accessor, Object keyInstance, DatabaseMapping mapping, org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, Object... keyElements) INTERNAL: Recursive method to set a field value in the given key instance. -
isCMP3Policy
public boolean isCMP3Policy()INTERNAL: Return if this policy is for CMP3. -
clone
INTERNAL: Clone the CMPPolicy -
convertClassNamesToClasses
INTERNAL: 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.- Parameters:
classLoader
-
-
createPrimaryKeyInstanceFromId
public Object createPrimaryKeyInstanceFromId(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Create an instance of the composite primary key class for the key object. -
createPrimaryKeyInstanceFromPrimaryKeyValues
public Object createPrimaryKeyInstanceFromPrimaryKeyValues(org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, Object... keyElements) INTERNAL: Create an instance of the composite primary key class for the key object. Yes the elementIndex looks strange but this is just a simple way to get the index to be pass-by-reference -
createPrimaryKeyInstance
public Object createPrimaryKeyInstance(Object object, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Create an instance of the Id class or value from the object. -
getClassInstance
INTERNAL: Return a new instance of the class provided. -
getPKClassInstance
INTERNAL: -
getPKClass
INTERNAL: -
createPrimaryKeyFromId
public Object createPrimaryKeyFromId(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: 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. -
createBeanUsingKey
public Object createBeanUsingKey(Object key, org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: 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.- Parameters:
key
- Object the primary key to use for initializing the bean's corresponding pk fields- Returns:
- Object
-
getKeyClassFields
INTERNAL:- Returns:
- Returns the keyClassFields.
-
isSingleKey
Check to see if there is a single key element. Iterate through the list of primary key elements and count only keys that are not part of the Multitenant identifier.- Parameters:
pkElementArray
-- Returns:
-