Recently I was wondering, what is the Change Indicator property that we see in each entity’s attribute?
In this post I will answer myself. ADF framework provides automatic “lost update” detection for entity objects to ensure that a user cannot unknowingly modify data that another user has updated and committed in the meantime. Typically, this check is performed by comparing the original values of each persistent entity attribute against the corresponding current column values in the database at the time the underlying row is locked. ADF framework checks for row changes as follow:
- When the entity cache is first populated, or whenever commit() is called, the framework saves a copy of the data as it is exist in the database. This copy is maintained even if the value in the cache is later changed.
- When the transaction attempts to acquire a lock, every attribute in the copy is compared with the corresponding table column. If any of these comparison fail, the frame work throws oracle.jbo.RowInconsistentException.
If you are attempting to acquire locks for many rows, and each row has a large number of column, this can be expensive operation. You can make the lost update detection more efficient by identifying any attributes of your entity whose values you know will be updated whenever the entity is modified. Typical candidates include a version number column or a set of attributes that you know will change every time any value in the row is changed. The change-indicator attribute’s value might be assigned by a database trigger you’ve written and refreshed in the entity object using the Refresh After Insert and Refresh After Update options (in the Edit Attribute dialog).When you use a change indicator, the framework only performs the comparison for attribute in the change indicator instead of for every entity attribute.