关于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
软考中级精品资料免费领
- 历年真题答案解析
- 备考技巧名师总结
- 高频考点精准押题
- 资料下载
- 历年真题
193.9 KB下载数265
191.63 KB下载数245
143.91 KB下载数1148
183.71 KB下载数642
644.84 KB下载数2756
相关文章
发现更多好内容猜你喜欢
AI推送时光机关于MSSQL audit记录1
数据库2024-04-02关于oracle 11g 安装笔记记录
数据库2024-04-02关于TypeScript的踩坑记录
数据库2024-04-02关于localStorage的存储,读取,删除
数据库2024-04-02关于BufferedReader的读取效率问题
数据库2024-04-02关于ADO中用_RecordsetPtr记录集添加记录的问题
数据库2023-08-08Flutter中关于angle的踩坑记录
数据库2024-04-02关于Swagger优化的实战记录
数据库2024-04-02关于vue2使用swiper4的踩坑记录
数据库2024-04-02PHP实现读取Excel文件的记录(二)
数据库2024-04-02PHP实现读取Excel文件的记录(一)
数据库2024-04-02php如何读取数据库前几条记录
数据库2023-07-05易语言怎么读取记录到编程框
数据库2023-09-25关于Vue3过渡动画的踩坑记录
数据库2024-04-02php怎么读取数据库前几条记录
数据库2023-05-14PHP怎么实现读取Excel文件的记录
数据库2023-06-29基于yoloV7添加关键点训练记录
数据库2023-09-04关于RowBounds分页原理、RowBounds的坑记录
数据库2023-05-17关于keras中卷积层Conv2D的学习记录
数据库2023-02-21 咦!没有更多了?去看看其它编程学习网 内容吧
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
软考中级精品资料免费领
- 历年真题答案解析
- 备考技巧名师总结
- 高频考点精准押题
- 资料下载
- 历年真题
193.9 KB下载数265
191.63 KB下载数245
143.91 KB下载数1148
183.71 KB下载数642
644.84 KB下载数2756