Class CloneCopyPolicy
- java.lang.Object
-
- org.eclipse.persistence.descriptors.copying.AbstractCopyPolicy
-
- org.eclipse.persistence.descriptors.copying.CloneCopyPolicy
-
- All Implemented Interfaces:
Serializable,Cloneable,CopyPolicy
public class CloneCopyPolicy extends AbstractCopyPolicy
Purpose: Allows a clone of an object to be created with a method that returns the cloned object. It is possible to define methods for two types of clones 1. methodName can be set to define the method EclipseLink uses to clone objects for it's own internal use. The objects created by this method will not be visible to the user, and instead used as a basis for comparison when a DeferredChangeDetectionPolicy used. This method will also be in place of the workingCopyMethod if it is not provided 2. workingCopyMethod this method is used to create the clone that is returned to the user when an Object is registered in a UnitOfWork
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CloneCopyPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectbuildClone(Object domainObject, Session session)Clone through calling the clone method.booleanbuildsNewInstance()Return false as a shallow clone is returned, not a new instance.ObjectbuildWorkingCopyClone(Object domainObject, Session session)Clone through the workingCopyClone method, or if not specified the clone method.ObjectbuildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow)Create a new instance, unless a workingCopyClone method is specified, then build a new instance and clone it.StringgetMethodName()Return the clone method name.StringgetWorkingCopyMethodName()Return the workingCopyClone method name.voidinitialize(Session session)Validate and build the methods.voidsetMethodName(String methodName)Set the clone method name.voidsetWorkingCopyMethodName(String methodName)Set the workingCopyClone method name.StringtoString()-
Methods inherited from class org.eclipse.persistence.descriptors.copying.AbstractCopyPolicy
clone, setDescriptor
-
-
-
-
Method Detail
-
buildClone
public Object buildClone(Object domainObject, Session session) throws DescriptorException
Clone through calling the clone method.- Specified by:
buildClonein interfaceCopyPolicy- Specified by:
buildClonein classAbstractCopyPolicy- Throws:
DescriptorException
-
buildWorkingCopyClone
public Object buildWorkingCopyClone(Object domainObject, Session session) throws DescriptorException
Clone through the workingCopyClone method, or if not specified the clone method.- Specified by:
buildWorkingCopyClonein interfaceCopyPolicy- Overrides:
buildWorkingCopyClonein classAbstractCopyPolicy- Throws:
DescriptorException
-
buildWorkingCopyCloneFromRow
public Object buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query, Object primaryKey, UnitOfWork uow) throws DescriptorException
Create a new instance, unless a workingCopyClone method is specified, then build a new instance and clone it.- Specified by:
buildWorkingCopyCloneFromRowin interfaceCopyPolicy- Overrides:
buildWorkingCopyCloneFromRowin classAbstractCopyPolicy- Throws:
DescriptorException
-
getMethodName
public String getMethodName()
Return the clone method name.
-
getWorkingCopyMethodName
public String getWorkingCopyMethodName()
Return the workingCopyClone method name. This is used to clone within a unit of work.
-
initialize
public void initialize(Session session) throws DescriptorException
Validate and build the methods.- Specified by:
initializein interfaceCopyPolicy- Overrides:
initializein classAbstractCopyPolicy- Throws:
DescriptorException
-
setMethodName
public void setMethodName(String methodName)
Set the clone method name.
-
setWorkingCopyMethodName
public void setWorkingCopyMethodName(String methodName)
Set the workingCopyClone method name. This is used to clone within a unit of work.
-
buildsNewInstance
public boolean buildsNewInstance()
Return false as a shallow clone is returned, not a new instance.
-
-