Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Configuring Copy Policy

The TopLink unit of work feature must be able to produce an exact copy (clone) persistent objects. Table 28-32 summarizes which descriptors support a copy policy.

Table 28-32 Configuring Descriptors with a Copy Policy

Descriptor | Using TopLink Workbench | Using Java
--- | --- | ---
Relational Descriptors |  |
Object-Relational Descriptors |  |
EIS Descriptors |  |
XML Descriptors |  |

TopLink supports two ways of copying objects:

- Instantiation policy: By default, TopLink creates a new copy of an object by using the currently configured instantiation policy (see "Configuring Instantiation Policy").

- Method: TopLink creates a new copy of an object by calling a method on the object that you specify. For example, you can specify the object's `clone` method (or any other appropriate method on the object).

## Using TopLink Workbench

To specify the copy policy for a descriptor, use this procedure:

1. Select a descriptor in the Navigator. Its properties appear in the Editor.

   If the Copying advanced property is not visible for the descriptor, right-click the descriptor and choose Select Advanced Properties > Copying from the context menu or from the Selected menu.

2. Click the Copying tab in the Editor.

   Figure 28-41 Copying Tab

Use the following information to enter data in each field on the tab:

Field | Description
--- | ---
Use Instantiation Policy | Creates a new instance of the object using the descriptor's instantiation policy (see "Configuring Instantiation Policy").
Use Clone Method | Specifies whether or not to call the `clone` method of the object. Select a method from the list.

## Using Java

Use one of the following `ClassDescriptor` methods to set the appropriate type of copy policy:

- `useCloneCopyPolicy()`: the object must provide a `clone` method

- `useCloneCopyPolicy(java.lang.String cloneMethodName)`

- `useInstantiationCopyPolicy()`