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


@ReturnInsert

Use @ReturnInsert to cause INSERT operations to return values back into the object being written. This allows for table default values, trigger or stored procedures computed values to be set back into the object.


NoteNote:

Returning is only supported with an Oracle Database and requires an INSERT RETURNING clause.

To use returning with other databases, a stored procedure with output parameters is used for the insert query.



Annotation Elements

Table 2-61 describes this annotation's elements.

Table 2-61 @ReturnInsert Annotation Elements

Annotation Element Description Default

returnOnly

(Optional) If specified (true), the mapping field will be excluded from the INSERT clause during SQL generation.

false



Usage

A @ReturnInsert annotation can only be specified on a Basic mapping.


Examples

Example 2-99 shows how to use the @ReturnInsert annotation. If you do not use an argument, EclipseLink accepts the default value, false.

Example 2-99 Using @ReturnInsert Annotation

@ReturnInsert(returnOnly=true)
 public String getFirstName() {
     return firstName;
 }

Example 2-100 shows how to use the <return-insert> element in the eclipselink-orm.xml file.

Example 2-100 Using <return-insert> XML

<basic name="firstName">
    <column name="FIRST_NAME"/>
    <return-insert read-only="true"/>
</basic>


See Also

For more information, see: