我的编程空间,编程开发者的网络收藏夹
学习永远不晚

关于VO读取记录

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

关于VO读取记录

关于VO读取记录

getRowCount()
Counts the total number of rows in this row set.

计算这个行集的行总数

This method retrieves all rows from the View Object by executing the View Object's query and then callingnext() until the last row is retrieved. Thus, since it iterates through the View Object one record at a time, this method may be slow.

该方法通过执行视图对象的查询从视图对象中获取所有行,然后调用next()直到最后一行被调用。于是,由于它通过视图对象一次迭代一条记录,因此该方法是比较慢的。

If you are working with a large number of rows, or if your application demands a fast response, usegetEstimatedRowCount to obtain a quicker count.

如果你操作一大堆行,或者你的应用需要一个快速的响应,使用getEstimatedRowCount获得一个更快的数量。

The following sample code uses getRowCount() to set up separate iterators for even numbered and odd numbered rows:

下面的代码使用getRowCount()为基数和偶数行创立独立的迭代器。

 // Default iterator gets even-numbered rows.
 // Second iterator gets odd-numbered rows.
 long nRows = vo.getRowCount();
 String msg = "";
 for (int i = 0; i < nRows; i +=2) {
 // Get and set row index values relative to a range.
 // Index of first row = 0.
 vo.setCurrentRowAtRangeIndex(i);
 Row currRow = vo.getCurrentRow();
 msg = " Default iterator (even): " + vo.getRangeIndexOf(currRow);
 printRow(currRow, msg);
 secondIter.setCurrentRowAtRangeIndex(i + 1);
 currRow = secondIter.getCurrentRow();
 msg = " Second iterator (odd): " + vo.getRangeIndexOf(currRow);
 printRow(secondIter.getCurrentRow(), msg);
 }


getRowCountInRange()
Counts the rows actually in the range.

计算范围内的实际行数

getRowCountInRange() :int
Gets the size of the current RowSet's range

获得当前RowSet(记录集)的范围大小。

getFetchedRowCount() :int
Counts the number of rows fetched from the JDBC result set.

计算从JDBC结果集抓取的行数。

This method delegates to the default RowSetIterator.

This method can be used to determine whether the View Object has read all the rows from the cursor. For example, getEstimatedRowCount returns an equivalent of count(*) on the View Object. ThegetFetchedRowCount() method returns the count of rows already fetched. If getFetchedRowCount() returns a value less than getEstimatedRowCount(), then the View Object has not read all rows from the cursor.

该方法被用于确定视图对象是否从游标中读取所有的行。例如,getEstimatedRowCount返回视图对象上count(*)相等的量。getFetchedRowCount()方法只返回已经抓取的行数。如果getFetchedRowCount()返回的值小于getEstimatedRowCount(),那么视图对象没有从游标中读到所有行。

getEstimatedRowCount

Makes an estimated count of the rows in this row set.

This method estimates the number of rows in the row count by calling getQueryHitCount (which performs a SELECT COUNT (*) FROM table). Internal logic in Business Components for Java keeps the EstimatedRowCount up-to-date as rows are inserted and removed. Thus, after the first call to this method, it can return the estimated count quickly.

For example:

// Get the rowcount again because of deleted or inserted row

rowCount = (int) iter.getRowSet().getEstimatedRowCount();


If you are working with a large number of rows, or if your application demands a fast response, use this method instead ofgetRowCount.

Note however, that this method might not be as accurate as getRowCount().

注意:但是,这个方法可能没有getRowCount准确。

To test whether the View Object has read all the rows from the cursor, you can use getEstimatedRowCount() in conjunction with getFetchedRowCount(). For example, getEstimatedRowCount() returns an equivalent of count(*) on the View Object. The getFetchedRowCount method returns the count of rows already fetched. If getFetchedRowCount() returns a value less than getEstimatedRowCount(), then the View Object has not read all rows from the cursor.


getFetchSize()
Gets the row pre-fetch size.

获得行的预先抓取大小

The framework will use this value to set the JDBC row pre-fetch size. Note that the row pre-fetch size has performance ramifications. A larger fetch size is more expensive in terms of memory usage than a smaller size. The default fetch size is 1 row.

框架将使用这个值去设定JDBC行预抓取大小。注意行预抓取大小影响性能。比较大的抓取大小就内存使用而言比小的抓取大小要更昂贵。 默认的抓取大小是一行。

If the value of setFetchMode(byte) is FETCH_ALL, then the value of setFetchSize is disregarded.

如果setFetchMode的值是FETCH_ALL,则setFetchSize将被忽略。

For each View Object, this method is customizable. Deciding what value to use could be made at runtime based on how many rows are expected for a particular View Object.

对于每个视图对象,这种方法是可定制的。可以在运行时基于一个特定视图对象预期的行数决定使用什么值进行设定。


getRangeSize()
Returns the range size of the iterator.

获得迭代器的范围大小。


测试代码:

PerAllPeopleVOImpl employerInstance=(PerAllPeopleVOImpl) this.getPerAllPeopleVO1();
int fetchedRowCount=employerInstance.getFetchedRowCount();
int rowCount=employerInstance.getRowCount();
int rowCountInRange=employerInstance.getRowCountInRange();
long estimatedRowCount= employerInstance.getEstimatedRowCount();
int rangeSize=employerInstance.getRangeSize();
int fetchSize=employerInstance.getFetchSize();
int allRowLength=employerInstance.getAllRowsInRange().length;

int employerCount=0;
while(employerInstance.hasNext())
{
PerAllPeopleVORowImpl eachEmployer= (PerAllPeopleVORowImpl)employerInstance.next();
String empName= eachEmployer.getLastName();
employerCount++;
}


logInfo("fetchedRowCount is "+fetchedRowCount);
logInfo("rowCount is "+rowCount);
logInfo("rowCountInRange is "+rowCountInRange);
logInfo("estimatedRowCount is "+estimatedRowCount);
logInfo("rangeSize is "+rangeSize);
logInfo("fetchSize is "+fetchSize);
logInfo("employerCount is "+employerCount);
logInfo("allRowLength is "+allRowLength);


测试结果:


fetchedRowCount is 0

rowCount is 1001

rowCountInRange is 1

estimatedRowCount is 1001

rangeSize is 1

fetchSize is 1

employerCount is 0

allRowLength is 1


问题:

实际数据库的记录数是:5 9924,distinct掉重复的person_id后,记录数是3 1113。

在页面上会报出如下警告:警告 - 查询已超出 1000 行。可能存在更多的行,请限制查询。


不知道是否与此设置有关。



关于next()方法:


next() :ROW
Gets the next row in the iterator.

在迭代器中获得下一行

This method delegates to the default RowSetIterator. If this method is called on a row set that has not yet been executed, executeQuery() is implicitly called.

这个方法委托给默认的RowSetIterator。如果这个方法在行集还没有被执行的时候被调用,将隐式调用executeQuery。

If the current row designation is to change, ViewRowImpl.validate() is called to validate the current row.

如果当前行的指定被改变,ViewRowImpl.validate()被调用验证当前行。

The row set has a "slot" before the first row, and one after the last row. When the row set is executed the iterator is positioned at the slot before the first row. If next() is invoked on a newly-executed row, the first row will be returned. If next() is called when the iterator is positioned on the last row of the row set, nullis returned and the iterator is positioned at the slot following the last row.

行集在第一行之前,和最后一行之后都有一个“空位”。当行集被执行时,迭代器定位在第一行之前的空位。如果next()在一个新执行的行上被调用,第一行将返回。

If the iterator is at the last row of the range when next() is called, RowSetListener.rangeScrolled()is called to send ScrollEvent to registered RowSetListeners.

当next()被调用时,如果迭代器在范围的最后一行,RowSetListener.rangeScrolled()被调用发送ScrollEvent到注册的RowSetListeners。

When successful, this method fires a NavigationEvent to registered RowSetListeners, by callingRowSetListener.navigated(). The row returned is designated as the current row.

当成功的时候,该方法通过调用RowSetListener.navigated()触发NavigationEvent 。返回的行被标志为当前行。

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

关于VO读取记录

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

关于ADO中用_RecordsetPtr记录集添加记录的问题

在ADO中,可以使用_RecordsetPtr来添加记录到记录集中。下面是一个示例代码:```cpp// 创建记录集对象_RecordsetPtr pRecordset("ADODB.Recordset");// 设置连接字符串CStrin
2023-08-08

php如何读取数据库前几条记录

这篇文章主要介绍“php如何读取数据库前几条记录”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“php如何读取数据库前几条记录”文章能帮助大家解决问题。使用SQL语句在PHP中,我们可以使用SQL语句
2023-07-05

易语言怎么读取记录到编程框

在易语言中,可以使用"打开文件"和"读取一行"的命令来读取记录到编程框。具体步骤如下:1. 首先,使用"打开文件"命令打开包含记录的文件。例如,可以使用以下代码:```文件句柄 = 打开文件("文件路径", "r")```其中,"文件路径"
2023-09-25

PHP怎么实现读取Excel文件的记录

这篇文章主要介绍“PHP怎么实现读取Excel文件的记录”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“PHP怎么实现读取Excel文件的记录”文章能帮助大家解决问题。首先安装Composer。com
2023-06-29

关于RowBounds分页原理、RowBounds的坑记录

这篇文章主要介绍了关于RowBounds分页原理、RowBounds的坑记录,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
2023-05-17

关于keras中卷积层Conv2D的学习记录

这篇文章主要介绍了关于keras中卷积层Conv2D的学习记录,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
2023-02-21

编程热搜

目录