Skip Headers

# Configuring Returning Policy

Previous

Next

Using a `ReturningPolicy`, you can obtain field values from the data source when inserting or updating an object. TopLink uses the values that the data source returns to update the object attributes that map to these fields. You can specify which fields to return for inserts and updates. For insert fields, you can also specify whether or not to include the field value in the insert operation.

A `ReturningPolicy` is useful when the data source provides default or initial field values through defaults, triggers, or stored procedures. You can also use a `ReturningPolicy` to allow the data source to assign a sequence or primary key value.

Any object attribute that you do not configure in a descriptor's `ReturningPolicy` receives the default behavior: in the context of a unit of work, if the attribute has changed, its value is written to the database. If the SQL statement invokes a trigger or stored procedure that modifies the database field, the database generated value is not reflected by the object.

Use caution when deciding on whether or not to use a `ReturningPolicy`, as doing so may effect insert or update performance and is not compatible with batch writing (see "Batch Writing").

By default, you can use a `ReturningPolicy` with an Oracle Database, in which case, TopLink uses the Oracle `RETURNING` clause (see "Using TopLink Workbench").

You can use a `ReturningPolicy` with a non-Oracle database if you configure your descriptor's insert or update query to use a stored procedure that returns the desired returned values as output parameters (see "Using Java").

Table: Descriptor Support for Fetch Group Configuration summarizes which descriptors support returning policy configuration.

Descriptor Support for Fetch Group Configuration

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

Footnote 1 EIS root descriptors only (see "EIS Root Descriptors").