Last Update: 26/5/2011
You can use this method safely(zero side effect) to add your logic for tweaking default query by setting bind variable values or additional where clause at run time.
Finally, in the post's comments, Jobinesh clarified the difference of using the prepareRowSetForQuery and executeQueryForCollection:
Why use this one and not executeQueryForCollection?
Well..good question. A couple of points for not using executeQueryForCollection...
1. The executeQueryForCollection(...) will never get invoked before getEstimatedRowCount() which is used for identifying the total result size. This may have serious side effects if you are modifying the query from executeQueryForCollection, as two different queries are getting executed - one for VO and the other on for rowCount. Table/Tree table will check for row count first and then displays records
2. If you need to modify the bind parameters values present in the query, executeQueryForCollection(..) is not the place as its too late and the values has already been extracted for execution.
Many thanx to Jobinesh for clarifying this.