Class CMPPolicy

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

public class CMPPolicy extends Object implements Serializable, Cloneable

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

See Also:
  • Field Details

    • forceUpdate

      protected Boolean forceUpdate
    • updateAllFields

      protected Boolean updateAllFields
    • pessimisticLockingPolicy

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

      protected 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:
    • UPDATE_MODIFICATIONS

      public static final int UPDATE_MODIFICATIONS
      defer updates
      See Also:
    • ALL_MODIFICATIONS

      public static final int ALL_MODIFICATIONS
      defer all modifications, inserts and deletes included (default)
      See Also:
    • 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:
    • AFTER_EJBCREATE

      public static final int AFTER_EJBCREATE
      issue SQL after ejbCreate but before ejbPostCreate
      See Also:
    • AFTER_EJBPOSTCREATE

      public static final int AFTER_EJBPOSTCREATE
      issue 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 PessimisticLockingPolicy 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 void setMappedClass(Class newMappedClass)
      PUBLIC: Define the mapped class. This is the class which was originally mapped in the MW
      Parameters:
      newMappedClass -
    • getMappedClass

      public 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:
      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

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

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

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

      public void internalSetUpdateAllFields(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
    • 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

      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, 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

      public CMPPolicy clone()
      INTERNAL: Clone the CMPPolicy
      Overrides:
      clone in class Object
    • convertClassNamesToClasses

      public void convertClassNamesToClasses(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 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

      public Object getClassInstance(Class<?> cls)
      INTERNAL: Return a new instance of the class provided.
    • getPKClassInstance

      public Object getPKClassInstance()
      INTERNAL:
    • getPKClass

      public Class 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

      protected CMPPolicy.KeyElementAccessor[] getKeyClassFields()
      INTERNAL:
      Returns:
      Returns the keyClassFields.
    • isSingleKey

      protected boolean isSingleKey(CMPPolicy.KeyElementAccessor[] pkElementArray)
      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: