OAViewObject中clearCache(),reset(),setMaxFetchSize(-1)的使用


今天在頁面跳轉之后,明明執行了查詢,且查詢語句正確的情況下,頁面不顯示數據,且點擊SubmitButton包瀏覽器后退異常。

代碼如下:

    OAViewObjectImpl vo=(OAViewObjectImpl)am.findViewObject("XXXVO1");
    vo.clearCache(); 
    vo.ExecuteQuery(headerid);
          
    public void ExecuteQuery(Number headerid)
    {
        clearCache();
        setWhereClauseParams(null);
        setWhereClauseParam(0, headerid);
        executeQuery();

    }

打印日志發現:
VO.getMaxFetchSize()==0;

VO.getFetchRowCount()==0;

所以頁面不顯示數據且觸發POST數據時導致瀏覽器后退異常。

代碼修改為如下即正常。

    OAViewObjectImpl vo=(OAViewObjectImpl)am.findViewObject("XXXVO1");
    vo.clearCache(); 
    vo.reset();
    vo.setMaxFetchSize(-1);
    vo.ExecuteQuery(headerid);
          
    public void ExecuteQuery(Number headerid)
    {
        clearCache();
        setWhereClauseParams(null);
        setWhereClauseParam(0, headerid);
        executeQuery();

    }

這使我對

    vo.clearCache(); 
    vo.reset();
    vo.setMaxFetchSize(-1);

Use the VO reset and clear cache both in the processFormRequest before redirecting to page again as well as in processRequest before initializing the VO.

But , Why???

 

於是對這三個方法產生了強烈的興趣。

查詢JDev Doc得到以下結果:

關於clearCache()方法的官方文檔介紹如下:

clearCache
public void clearCache()Clears the view object cache.
This method can be called for resource conservation. Calling this method also forces an automatic re-execution of the query for all RowSets, which refreshes the cache from the database.


Specified by:
clearCache in interface ViewObject
Overrides:
clearCache in class OAJboViewObjectImpl

關於reset()方法暫時未找到文檔介紹。

個人理解reset()方法會重置VO,包括VO中的指針。

關於setMaxFetchSize()的官方文檔介紹如下:

 

setMaxFetchSize
public void setMaxFetchSize(int size)Maximum number of rows to fetch when a query is executed. This number takes effect the next time a query is executed.
Passing '-1' will retrieve all the rows. This is default behavior. (For OA Framework view objects, however, OA Framework initializes the maximum fetch size to be the value specified by "VO_MAX_FETCH_SIZE" profile option value.)

 

Passing '0' will result in the database query not being executed and also mark the view object as properly prepared for query execution.

 

Specified by:
setMaxFetchSize in interface ViewObject
Overrides:
setMaxFetchSize in class ViewObjectImpl
Parameters:
size - maximum number of rows to fetch
See Also:
executeQuery(), isPreparedForExecution(), setPreparedForExecution(boolean flag)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM