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)

 

转载于:https://www.cnblogs.com/huanghongbo/p/5373307.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值