Search code examples
oracle-adfjdeveloper

Oracle ADF: How to clear ViewObject cache programmatically


I am developing a adf web application using jdeveloper 11.1.2.4. I have a search form as below.

enter image description here

Actually when I first visit this page I am getting an empty form. After performing some search operations I visited another page, and then again when I come back to this page, the page retains the previous search results. At this point of time when I am trying to modify anthing means updating or deleting I am getting the follwoing excepiton.

Another user has changed the row with primary key oracle.jbo.Key[1 ].

The modifications has successfully done when I accessed this page for the first time. I tried with clearing viewobject and entityobject cache. But no luck.

I think if I get a fresh page everytime when I visit this page this problem could be resolved. Or if there is any other better solution please let me know .

Please help me to remove this exception. Please suggest me with a solution.

Thanks in advance.


Solution

  • We usually suppress this exception on complex ADF systems by overriding lock() method in all our Entity Impl classes:

      /**
         * customizing locking management:
         * Because attribute  values  can change 'outside' ADF standard life cycle,
         * when optimistic locking executes, the exception "Another User Changed the Row" is thrown.
         * In this case, we execute locking again, ignoring the exception
         */
        public void lock() {
            try {
                super.lock();
            } catch (oracle.jbo.RowInconsistentException e) {
                if (e.getErrorCode().equals("25014")) {
                    super.lock();
                } else
                    throw e;
            }
        }