Wednesday, October 9, 2013

List All Dirty Entities in the current transaction

I was asked once if it was possible to list all dirty entities in the transaction regardless of the entity type.
After some thinking and reading, I reached the solution I am about to describe:

1)override the default DBTransactionImpl2 as described in:Extending ADF framework base classes
2)override the getTransactionPostListenersList and make it public.

the mentioned function returns a list that contain classes that implements the TransactionPostListener interface, such as :ViewObjectImpl,EntityImpl.

you can test the object by using the following code :
  transactionPostListener instanceof EntityImpl
to see if it's an Entity.

please note that if you find a ViewObject in the list that it does not necessarily have a dirty row.
simply iterating the rows of the ViewObject will add it to the list.

some other functions that may be of value are:
--addTransactionStateListener; by testing the method, found that this is the method used to add the ViewObject to the list returned by :getTransactionPostListenersList.
--addTransactionPostListenerNoCheck: by testing the method, found that this is the method used to add the Entity to the list returned by :getTransactionPostListenersList.
-- removeTransactionPostListener: by testing the method, found that this is the method used to remove the Post Listener from the list returned by :getTransactionPostListenersList.

No comments:

Post a Comment