重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

关于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 currentRowSet'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 sendScrollEvent 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。返回的行被标志为当前行。


网页题目:关于VO读取记录
网页URL:http://cqcxhl.cn/article/jieisp.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP