Java Persistence API (JPA) Extensions Reference for EclipseLink, Release 2.4
  Go To Table Of Contents
 Search
 PDFComments
Comments


@CloneCopyPolicy

Use @CloneCopyPolicy to specify an org.eclipse.persistence.descriptors.copying.CloneCopyPolicy on an Entity.


Annotation Elements

Table 2-11 describes this annotation's elements.

Table 2-11 @CloneCopyPolicy Annotation Elements

Annotation Element Description Default

method

(Optional) The method that will be used to create a clone for comparison with EclispeLink's DeferredChangeDetectionPolicy.


workingCopyMethod

(Optional) The workingCopyoMethod that will be used to create a clone that will be used when registering an object in an EclipseLink UnitOfWork.




NoteNote:

You must specify either a method or workingCopyMenthod.



Usage

The clone method should perform a shallow clone of the object. This can be used to clone non-persistent fields from a instance in the shared cache.

You can specify @CloneCopyPolicy on an Entity, MappedSuperclass, or Embeddable class.


Examples

Example 2-25 and Example 2-26 show several examples of the @CloneCopyPolicy annotation and <clone-copy-policy> XML element, respectively.

Example 2-25 Using @CloneCopyPolicy Annotation

@CloneCopyPolicy(method="myClone")
@CloneCopyPolicy(method="myClone", workingCopyMethod="myWorkingCopyClone")
@CloneCopyPolicy(workingCopyMethod="myWorkingCopyClone")

Example 2-26 Using <clone-copy-policy> XML

<clone-copy-policy type="copy" method="myClone" workingCopyMethod="myWorkingCopyClone"/>
<clone-copy-policy type="copy" workingCopyMethod="myWorkingCopyClone"/>
<clone-copy-policy type="copy" method="myClone"/>
 


See Also

For more information, see: