What Does executeEmptyRowSet() Do?
By Steve Muench on Nov 25, 2009
A user asks "I've seen a few forum posts that say to use executeEmptyRowSet to programmatically clear the VO? What does the method actually do - I didn't see anything in the javadoc."
I filed a bug 9156214 to get the JavaDoc improved in a future release, but in the interim I'll explain it here.
The RowSet.executeEmptyRowSet() method performs the logical equivalent of executing your view object with a predicate like "WHERE 1 = 2" (always false!) in a more efficient way.The result is that the rowset has no rows in it (just like if you had executed a query that returned no rows), however it achieves this without actually sending a query to the database.
After calling executeEmptyRowSet(), the rowset it empty and the VO has its "isExecuted" flag marked to true. This would mean that subsequent attempts to reference data in the VO from the data binding layer will not try to implicitly execute the query because they notice the VO is already executed.
The rowset persists information about its state to the state management passivation snapshot -- see section 40.5 What Model State Is Saved and When It Is Cleaned Up in the dev guide for more information on this -- so that during the state activation a view object that had previously been executed as empty via executeEmptyRowSet() will be again activated as empty to return to the same state it was in at the moment of state passivation.