EclipseLink 2.2.0, build 'v20110202-r8913' API Reference

org.eclipse.persistence.descriptors
Class CMPPolicy

java.lang.Object
  extended by org.eclipse.persistence.descriptors.CMPPolicy
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
org.eclipse.persistence.internal.jpa.CMP3Policy

public class CMPPolicy
extends java.lang.Object
implements java.io.Serializable

Description: Place holder for CMP specific information. This class can be set on the ClassDescriptor.

See Also:
PessimisticLockingPolicy, Serialized Form
Since:
TopLink 10.1.3

Nested Class Summary
protected static interface CMPPolicy.KeyElementAccessor
          INTERNAL: This is the interface used to encapsulate the the type of key class element
protected  class CMPPolicy.KeyIsElementAccessor
          INTERNAL: This class will be used when the keyClass is a primitive
 
Field Summary
static int AFTER_EJBCREATE
          issue SQL after ejbCreate but before ejbPostCreate
static int AFTER_EJBPOSTCREATE
          issue SQL after ejbPostCreate
static int ALL_MODIFICATIONS
          defer all modifications, inserts and deletes included (default)
protected  ClassDescriptor descriptor
           
protected  java.lang.Boolean forceUpdate
           
protected  java.lang.Class mappedClass
          Class originally mapped, before anything was generated.
protected  int modificationDeferralLevel
          The object deferral level.
protected  int nonDeferredCreateTime
          This setting will allow customers to control when Toplink will issue the insert SQL for CMP beans.
static int NONE
          defer no changes
protected  PessimisticLockingPolicy pessimisticLockingPolicy
          Allow the bean to always be locked as it enters a new transaction.
static int UNDEFINED
          undefined if it is non-deferred issue sql at create
static int UPDATE_MODIFICATIONS
          defer updates
protected  java.lang.Boolean updateAllFields
           
 
Constructor Summary
CMPPolicy()
           
 
Method Summary
 void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
          INTERNAL: Convert all the class-name-based settings in this object to actual class-based settings.
 java.lang.Object createBeanUsingKey(java.lang.Object key, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Use the key to create a bean and initialize its primary key fields.
 java.lang.Object createPrimaryKeyFromId(java.lang.Object key, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Use the key to create a EclipseLink primary key.
 java.lang.Object createPrimaryKeyInstance(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Create an instance of the Id class or value from the object.
 java.lang.Object createPrimaryKeyInstanceFromId(java.lang.Object key, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Create an instance of the composite primary key class for the key object.
 java.lang.Object createPrimaryKeyInstanceFromPrimaryKeyValues(org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, java.lang.Object... keyElements)
          INTERNAL: Create an instance of the composite primary key class for the key object.
 java.lang.Object getClassInstance(java.lang.Class cls)
          INTERNAL: Return a new instance of the class provided.
 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.
 ClassDescriptor getDescriptor()
          INTERNAL:
 boolean getForceUpdate()
          ADVANCED: Return true if descriptor is set to always update all registered objects of this type
protected  CMPPolicy.KeyElementAccessor[] getKeyClassFields()
          INTERNAL:
 java.lang.Class getMappedClass()
          PUBLIC: Answer the mapped class.
 int getNonDeferredCreateTime()
          ADVANCED: This setting is only available for CMP beans that are not being deferred.
 PessimisticLockingPolicy getPessimisticLockingPolicy()
          PUBLIC: Return the policy for bean pessimistic locking
 java.lang.Class getPKClass()
          INTERNAL:
 java.lang.Object getPKClassInstance()
          INTERNAL:
 boolean getUpdateAllFields()
          ADVANCED: Return true if descriptor is set to update all fields for an object of this type when an update occurs.
 boolean hasPessimisticLockingPolicy()
          PUBLIC: Return true if bean pessimistic locking is configured
 void initialize(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Initialize the CMPPolicy settings.
 java.lang.Boolean internalGetForceUpdate()
          INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.
 java.lang.Boolean internalGetUpdateAllFields()
          INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.
 void internalSetForceUpdate(java.lang.Boolean newForceUpdateValue)
          INTERNAL: internal method to set the tri-state value.
 void internalSetUpdateAllFields(java.lang.Boolean newUpdateAllFieldsValue)
          INTERNAL: internal method to set the tri-state value.
 boolean isCMP3Policy()
          INTERNAL: Return if this policy is for CMP3.
 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, java.lang.Object keyInstance, DatabaseMapping mapping, org.eclipse.persistence.internal.sessions.AbstractSession session, int[] elementIndex, java.lang.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(java.lang.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 setPessimisticLockingPolicy(PessimisticLockingPolicy policy)
          PUBLIC: Configure bean pessimistic locking
 void setUpdateAllFields(boolean shouldUpdatAllFields)
          ADVANCED: Configure whether TopLink should update all fields for an object of this type when an update occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

forceUpdate

protected java.lang.Boolean forceUpdate

updateAllFields

protected java.lang.Boolean updateAllFields

pessimisticLockingPolicy

protected PessimisticLockingPolicy pessimisticLockingPolicy
Allow the bean to always be locked as it enters a new transaction.


mappedClass

protected java.lang.Class mappedClass
Class originally mapped, before anything was generated.


descriptor

protected ClassDescriptor descriptor

modificationDeferralLevel

protected int modificationDeferralLevel
The object deferral level. This controls when objects changes will be sent to the Database.


NONE

public static final int NONE
defer no changes

See Also:
Constant Field Values

UPDATE_MODIFICATIONS

public static final int UPDATE_MODIFICATIONS
defer updates

See Also:
Constant Field Values

ALL_MODIFICATIONS

public static final int ALL_MODIFICATIONS
defer all modifications, inserts and deletes included (default)

See Also:
Constant Field Values

nonDeferredCreateTime

protected int nonDeferredCreateTime
This setting will allow customers to control when Toplink will issue the insert SQL for CMP beans.


UNDEFINED

public static final int UNDEFINED
undefined if it is non-deferred issue sql at create

See Also:
Constant Field Values

AFTER_EJBCREATE

public static final int AFTER_EJBCREATE
issue SQL after ejbCreate but before ejbPostCreate

See Also:
Constant Field Values

AFTER_EJBPOSTCREATE

public static final int AFTER_EJBPOSTCREATE
issue SQL after ejbPostCreate

See Also:
Constant Field Values
Constructor Detail

CMPPolicy

public CMPPolicy()
Method Detail

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 PessimisticLockingPolicy getPessimisticLockingPolicy()
PUBLIC: Return the policy for bean pessimistic locking

See Also:
#org.eclipse.persistence.descriptors.PessimisticLockingPolicy

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 void setMappedClass(java.lang.Class newMappedClass)
PUBLIC: Define the mapped class. This is the class which was originally mapped in the MW

Parameters:
Class - newMappedClass

getMappedClass

public java.lang.Class 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 void setPessimisticLockingPolicy(PessimisticLockingPolicy policy)
PUBLIC: Configure bean pessimistic locking

Parameters:
PessimisticLockingPolicy - policy
See Also:
#org.eclipse.persistence.descriptors.PessimisticLockingPolicy

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:
boolean - 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:
boolean - shouldUpdatAllFields

internalGetForceUpdate

public java.lang.Boolean internalGetForceUpdate()
INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.


internalGetUpdateAllFields

public java.lang.Boolean internalGetUpdateAllFields()
INTERNAL: return internal tri-state value so we can decide whether to inherit or not at init time.


internalSetForceUpdate

public void internalSetForceUpdate(java.lang.Boolean newForceUpdateValue)
INTERNAL: internal method to set the tri-state value. This is done in InheritancePolicy at init time.


internalSetUpdateAllFields

public void internalSetUpdateAllFields(java.lang.Boolean newUpdateAllFieldsValue)
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

getDescriptor

public ClassDescriptor getDescriptor()
INTERNAL:

Returns:
Returns the owningDescriptor.

setDescriptor

public void setDescriptor(ClassDescriptor owningDescriptor)
INTERNAL:

Parameters:
owningDescriptor - The owningDescriptor to set.

setFieldValue

protected void setFieldValue(CMPPolicy.KeyElementAccessor accessor,
                             java.lang.Object keyInstance,
                             DatabaseMapping mapping,
                             org.eclipse.persistence.internal.sessions.AbstractSession session,
                             int[] elementIndex,
                             java.lang.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.


convertClassNamesToClasses

public void convertClassNamesToClasses(java.lang.ClassLoader classLoader)
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 java.lang.Object createPrimaryKeyInstanceFromId(java.lang.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 java.lang.Object createPrimaryKeyInstanceFromPrimaryKeyValues(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                     int[] elementIndex,
                                                                     java.lang.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 java.lang.Object createPrimaryKeyInstance(java.lang.Object object,
                                                 org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Create an instance of the Id class or value from the object.


getClassInstance

public java.lang.Object getClassInstance(java.lang.Class cls)
INTERNAL: Return a new instance of the class provided.


getPKClassInstance

public java.lang.Object getPKClassInstance()
INTERNAL:


getPKClass

public java.lang.Class getPKClass()
INTERNAL:


createPrimaryKeyFromId

public java.lang.Object createPrimaryKeyFromId(java.lang.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 java.lang.Object createBeanUsingKey(java.lang.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

protected CMPPolicy.KeyElementAccessor[] getKeyClassFields()
INTERNAL:

Returns:
Returns the keyClassFields.

EclipseLink 2.2.0, build 'v20110202-r8913' API Reference