Synchronizing with Trigger-Assigned Values
When a database trigger updates the underlying column value during insert or update operations, you can select the respective Refresh After Insert or Refresh After Update check boxes to ensure that the framework automatically retrieves the modified value and keeps the entity object and database row in sync. The entity object then uses the Oracle SQL RETURNING INTO feature to return the modified column back to your application in a single database round-trip.
One common case for Refresh After Insert occurs when a primary key attribute value is assigned by a BEFORE INSERT FOR EACH ROW trigger. Often the trigger assigns the primary key from a database sequence. In this case, you can set the Attribute Type to the built-in data type DBSequence. Setting this data type automatically enables the Refresh After Insert property.
When you create a new entity row whose primary key is a DBSequence, a unique negative number gets assigned as its temporary value. This value acts as the primary key for the duration of the transaction in which it is created. At transaction commit time, the entity object issues its INSERT operation using the RETURNING INTO clause to retrieve the actual database trigger–assigned primary key value. Any related new entities that previously used the temporary negative value as a foreign key will get that value updated to reflect the actual new primary key of the master. You can set the Updatable property of a DBSequence-valued primary key to Never, because the end user never needs to update this value.