Thursday, March 20, 2014

Effective use of getEntityState() and getPostState() methods in EOImpl class in Oracle ADF

You can use the getEntityState() and getPostState() methods to access the current state of an entity row in your business logic code.

The getEntityState() method returns the current state of an entity row with regard to the transaction

getPostState() method returns the current state of an entity row with regard to the database after using the postChanges() method to post pending changes without committing the transaction.

The sample code is as below

public void postChanges(TransactionEvent transactionEvent) {
    /* If current entity is new or modified */
    if (getPostState() == STATUS_NEW || getPostState() == STATUS_MODIFIED) {
    }
}

The possible outcomes of the getPostState() method are as follows
  • 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_NEW - if this Entity Object is new and not yet posted to the database.
  • STATUS_INITIALIZED - if this Entity Object is new and the client code marks it to be temporary by calling Row.setNewRowState method.
  • 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