Thursday, September 26, 2013

Various Entity States in ADF


Below are the list of various entity states, which are helpful to determine whether entity has been updated or not.

Below is how we can determine the state of an entity.
 VORowImpl newRow = (VORowImpl )getVO1().getCurrentRow();
        EOImpl eo = (EOImpl) newRow.getEntity(0);
        byte newRowStatus = eo.getEntityState();
        if (newRowStatus ==  eo.STATUS_NEW){
            isNewRow = true;
        }

States are set to one of these values: STATUS_INITIALIZEDSTATUS_NEWSTATUS_MODIFIEDSTATUS_DELETED and STATUS_DEAD based on whether the Entity Object is being created, updated, deleted, or rolled back, respectively. These operations can set either or both the post-state and the Entity-state. The status values have a slightly different meaning depending on whether they are set for an Entity-state or a post-state:
  • For Entity-state:
    • STATUS_UNMODIFIED - if this Entity Object originated in the database and is unmodified, or if modifications have been committed to the database.
    • STATUS_MODIFIED - if this Entity Object originated in the database, and has been modified in the current transaction.
    • STATUS_NEW - if this Entity Object is new in the current transaction.
    • STATUS_DELETED - if this Entity Object has been deleted in the current transaction.
    • STATUS_DEAD - if this Entity Object is new in the current transaction and has been deleted.
  • For post-state:
    • STATUS_UNMODIFIED - if this Entity Object has been queried from the database and is unchanged, or if it has been posted to the database.
    • STATUS_MODIFIED - if this Entity Object has been queried from the database and has changed.
    • STATUS_INITIALIZED - if this Entity Object is new and the client application changed it's state to make this Object temporary.
    • STATUS_NEW - if this Entity Object is new in the post-cycle.
    • STATUS_DELETED - if this Entity Object has been marked for deletion.
    • STATUS_DEAD - if this Entity Object is new, but has been deleted.

No comments:

Post a Comment