Class CMP3Policy

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
    Direct Known Subclasses:
    DynamicIdentityPolicy

    public class CMP3Policy
    extends org.eclipse.persistence.descriptors.CMPPolicy
    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:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.eclipse.persistence.descriptors.CMPPolicy

        org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor, org.eclipse.persistence.descriptors.CMPPolicy.KeyIsElementAccessor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor> fieldToAccessorMap
      Used to look up the KeyElementAccessor for a specific DatabaseField, used for resolving DerivedIds
      protected org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] keyClassFields
      Stores the fields for this classes compound primary key class if required.
      protected java.lang.Class pkClass  
      protected java.lang.String pkClassName  
      • Fields inherited from class org.eclipse.persistence.descriptors.CMPPolicy

        AFTER_EJBCREATE, AFTER_EJBPOSTCREATE, ALL_MODIFICATIONS, descriptor, forceUpdate, mappedClass, modificationDeferralLevel, nonDeferredCreateTime, NONE, pessimisticLockingPolicy, UNDEFINED, UPDATE_MODIFICATIONS, updateAllFields
    • Constructor Summary

      Constructors 
      Constructor Description
      CMP3Policy()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addReadOnlyMappings​(org.eclipse.persistence.descriptors.ClassDescriptor aDescriptor, org.eclipse.persistence.internal.helper.DatabaseField field, java.util.List allMappings)
      INTERNAL: Add the writable mapping for the given field to the allMappings list.
      protected void addWritableMapping​(org.eclipse.persistence.descriptors.ClassDescriptor aDescriptor, org.eclipse.persistence.internal.helper.DatabaseField field, java.util.List allMappings)
      INTERNAL: Add the read only mappings for the given field to the allMappings list.
      CMP3Policy clone()
      INTERNAL: Clone the CMP3Policy
      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.
      protected java.lang.reflect.Field getField​(java.lang.Class cls, java.lang.String fieldName)
      INTERNAL:
      protected org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] getKeyClassFields()
      INTERNAL:
      java.lang.Class getPKClass()
      INTERNAL: Return the java Class representing the primary key class name
      java.lang.Object getPKClassInstance()
      INTERNAL:
      java.lang.String getPKClassName()
      INTERNAL:
      java.lang.Object getPkValueFromKeyForField​(java.lang.Object key, org.eclipse.persistence.internal.helper.DatabaseField field, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Pull the value for the field from the key.
      void initialize​(org.eclipse.persistence.descriptors.ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialize the CMPPolicy settings.
      protected org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] initializePrimaryKeyFields​(java.lang.Class keyClass, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Cache the bean's primary key fields so speed up creating of primary key objects and initialization of beans.
      boolean isCMP3Policy()
      INTERNAL: Return if this policy is for CMP3.
      void remoteInitialize​(org.eclipse.persistence.descriptors.ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Initialize the CMPPolicy settings for remote sessions.
      void setPKClass​(java.lang.Class pkClass)
      ADVANCED:
      void setPrimaryKeyClassName​(java.lang.String pkClassName)
      INTERNAL:
      • Methods inherited from class org.eclipse.persistence.descriptors.CMPPolicy

        createPrimaryKeyInstance, createPrimaryKeyInstanceFromId, createPrimaryKeyInstanceFromPrimaryKeyValues, getClassInstance, getDeferModificationsUntilCommit, getDescriptor, getForceUpdate, getMappedClass, getNonDeferredCreateTime, getPessimisticLockingPolicy, getUpdateAllFields, hasPessimisticLockingPolicy, internalGetForceUpdate, internalGetUpdateAllFields, internalSetForceUpdate, internalSetUpdateAllFields, isSingleKey, setDeferModificationsUntilCommit, setDescriptor, setFieldValue, setForceUpdate, setMappedClass, setNonDeferredCreateTime, setPessimisticLockingPolicy, setUpdateAllFields
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • keyClassFields

        protected transient org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] keyClassFields
        Stores the fields for this classes compound primary key class if required.
      • fieldToAccessorMap

        protected transient java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor> fieldToAccessorMap
        Used to look up the KeyElementAccessor for a specific DatabaseField, used for resolving DerivedIds
      • pkClassName

        protected java.lang.String pkClassName
      • pkClass

        protected java.lang.Class pkClass
    • Constructor Detail

      • CMP3Policy

        public CMP3Policy()
    • Method Detail

      • addWritableMapping

        protected void addWritableMapping​(org.eclipse.persistence.descriptors.ClassDescriptor aDescriptor,
                                          org.eclipse.persistence.internal.helper.DatabaseField field,
                                          java.util.List allMappings)
        INTERNAL: Add the read only mappings for the given field to the allMappings list.
        Parameters:
        aDescriptor -
        field -
        allMappings -
      • addReadOnlyMappings

        protected void addReadOnlyMappings​(org.eclipse.persistence.descriptors.ClassDescriptor aDescriptor,
                                           org.eclipse.persistence.internal.helper.DatabaseField field,
                                           java.util.List allMappings)
        INTERNAL: Add the writable mapping for the given field to the allMappings list.
        Parameters:
        aDescriptor -
        field -
        allMappings -
      • clone

        public CMP3Policy clone()
        INTERNAL: Clone the CMP3Policy
        Overrides:
        clone in class org.eclipse.persistence.descriptors.CMPPolicy
      • 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.
        Overrides:
        convertClassNamesToClasses in class org.eclipse.persistence.descriptors.CMPPolicy
        Parameters:
        classLoader -
      • isCMP3Policy

        public boolean isCMP3Policy()
        INTERNAL: Return if this policy is for CMP3.
        Overrides:
        isCMP3Policy in class org.eclipse.persistence.descriptors.CMPPolicy
      • setPrimaryKeyClassName

        public void setPrimaryKeyClassName​(java.lang.String pkClassName)
        INTERNAL:
      • getPKClass

        public java.lang.Class getPKClass()
        INTERNAL: Return the java Class representing the primary key class name
        Overrides:
        getPKClass in class org.eclipse.persistence.descriptors.CMPPolicy
      • setPKClass

        public void setPKClass​(java.lang.Class pkClass)
        ADVANCED:
      • getPKClassName

        public java.lang.String getPKClassName()
        INTERNAL:
      • getPKClassInstance

        public java.lang.Object getPKClassInstance()
        INTERNAL:
        Overrides:
        getPKClassInstance in class org.eclipse.persistence.descriptors.CMPPolicy
      • 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.
        Overrides:
        createPrimaryKeyFromId in class org.eclipse.persistence.descriptors.CMPPolicy
      • getField

        protected java.lang.reflect.Field getField​(java.lang.Class cls,
                                                   java.lang.String fieldName)
                                            throws java.lang.NoSuchFieldException
        INTERNAL:
        Parameters:
        cls -
        fieldName -
        Returns:
        the field from the class with name equal to fieldName.
        Throws:
        java.lang.NoSuchFieldException
      • 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.
        Overrides:
        createBeanUsingKey in class org.eclipse.persistence.descriptors.CMPPolicy
        Parameters:
        key - Object the primary key to use for initializing the bean's corresponding pk fields
        Returns:
        Object
      • initializePrimaryKeyFields

        protected org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] initializePrimaryKeyFields​(java.lang.Class keyClass,
                                                                                                                org.eclipse.persistence.internal.sessions.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.
      • getKeyClassFields

        protected org.eclipse.persistence.descriptors.CMPPolicy.KeyElementAccessor[] getKeyClassFields()
        INTERNAL:
        Overrides:
        getKeyClassFields in class org.eclipse.persistence.descriptors.CMPPolicy
        Returns:
        Returns the keyClassFields.
      • getPkValueFromKeyForField

        public java.lang.Object getPkValueFromKeyForField​(java.lang.Object key,
                                                          org.eclipse.persistence.internal.helper.DatabaseField field,
                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: 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
      • initialize

        public void initialize​(org.eclipse.persistence.descriptors.ClassDescriptor descriptor,
                               org.eclipse.persistence.internal.sessions.AbstractSession session)
                        throws org.eclipse.persistence.exceptions.DescriptorException
        INTERNAL: Initialize the CMPPolicy settings.
        Overrides:
        initialize in class org.eclipse.persistence.descriptors.CMPPolicy
        Throws:
        org.eclipse.persistence.exceptions.DescriptorException
      • remoteInitialize

        public void remoteInitialize​(org.eclipse.persistence.descriptors.ClassDescriptor descriptor,
                                     org.eclipse.persistence.internal.sessions.AbstractSession session)
                              throws org.eclipse.persistence.exceptions.DescriptorException
        INTERNAL: Initialize the CMPPolicy settings for remote sessions.
        Overrides:
        remoteInitialize in class org.eclipse.persistence.descriptors.CMPPolicy
        Throws:
        org.eclipse.persistence.exceptions.DescriptorException