新聞中心
關(guān)于VO讀取記錄
getRowCount()
Counts the total number of rows in this row set.

為金堂縣等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及金堂縣網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、金堂縣網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
計算這個行集的行總數(shù)
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.
該方法通過執(zhí)行視圖對象的查詢從視圖對象中獲取所有行,然后調(diào)用next()直到最后一行被調(diào)用。于是,由于它通過視圖對象一次迭代一條記錄,因此該方法是比較慢的。
If you are working with a large number of rows, or if your application demands a fast response, usegetEstimatedRowCount to obtain a quicker count.
如果你操作一大堆行,或者你的應(yīng)用需要一個快速的響應(yīng),使用getEstimatedRowCount獲得一個更快的數(shù)量。
The following sample code uses getRowCount() to set up separate iterators for even numbered and odd numbered rows:
下面的代碼使用getRowCount()為基數(shù)和偶數(shù)行創(chuàng)立獨立的迭代器。
// 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.
計算范圍內(nèi)的實際行數(shù)
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結(jié)果集抓取的行數(shù)。
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()方法只返回已經(jīng)抓取的行數(shù)。如果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().
注意:但是,這個方法可能沒有g(shù)etRowCount準確。
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.
獲得行的預(yù)先抓取大小
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.
框架將使用這個值去設(shè)定JDBC行預(yù)抓取大小。注意行預(yù)抓取大小影響性能。比較大的抓取大小就內(nèi)存使用而言比小的抓取大小要更昂貴。 默認的抓取大小是一行。
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.
對于每個視圖對象,這種方法是可定制的??梢栽谶\行時基于一個特定視圖對象預(yù)期的行數(shù)決定使用什么值進行設(shè)定。
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);
測試結(jié)果:
fetchedRowCount is 0
rowCount is 1001
rowCountInRange is 1
estimatedRowCount is 1001
rangeSize is 1
fetchSize is 1
employerCount is 0
allRowLength is 1
問題:
實際數(shù)據(jù)庫的記錄數(shù)是:5 9924,distinct掉重復(fù)的person_id后,記錄數(shù)是3 1113。
在頁面上會報出如下警告:警告 - 查詢已超出 1000 行。可能存在更多的行,請限制查詢。
不知道是否與此設(shè)置有關(guān)。
關(guān)于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。如果這個方法在行集還沒有被執(zhí)行的時候被調(diào)用,將隱式調(diào)用executeQuery。
If the current row designation is to change, ViewRowImpl.validate() is called to validate the current row.
如果當前行的指定被改變,ViewRowImpl.validate()被調(diào)用驗證當前行。
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.
行集在第一行之前,和最后一行之后都有一個“空位”。當行集被執(zhí)行時,迭代器定位在第一行之前的空位。如果next()在一個新執(zhí)行的行上被調(diào)用,第一行將返回。
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()被調(diào)用時,如果迭代器在范圍的最后一行,RowSetListener.rangeScrolled()被調(diào)用發(fā)送ScrollEvent到注冊的RowSetListeners。
When successful, this method fires a NavigationEvent to registered RowSetListeners, by callingRowSetListener.navigated(). The row returned is designated as the current row.
當成功的時候,該方法通過調(diào)用RowSetListener.navigated()觸發(fā)NavigationEvent。返回的行被標志為當前行。
getRowCount()
Counts the total number of rows in this row set.
為金堂縣等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及金堂縣網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、金堂縣網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
計算這個行集的行總數(shù)
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.
該方法通過執(zhí)行視圖對象的查詢從視圖對象中獲取所有行,然后調(diào)用next()直到最后一行被調(diào)用。于是,由于它通過視圖對象一次迭代一條記錄,因此該方法是比較慢的。
If you are working with a large number of rows, or if your application demands a fast response, usegetEstimatedRowCount to obtain a quicker count.
如果你操作一大堆行,或者你的應(yīng)用需要一個快速的響應(yīng),使用getEstimatedRowCount獲得一個更快的數(shù)量。
The following sample code uses getRowCount() to set up separate iterators for even numbered and odd numbered rows:
下面的代碼使用getRowCount()為基數(shù)和偶數(shù)行創(chuàng)立獨立的迭代器。
// 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.
計算范圍內(nèi)的實際行數(shù)
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結(jié)果集抓取的行數(shù)。
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()方法只返回已經(jīng)抓取的行數(shù)。如果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().
注意:但是,這個方法可能沒有g(shù)etRowCount準確。
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.
獲得行的預(yù)先抓取大小
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.
框架將使用這個值去設(shè)定JDBC行預(yù)抓取大小。注意行預(yù)抓取大小影響性能。比較大的抓取大小就內(nèi)存使用而言比小的抓取大小要更昂貴。 默認的抓取大小是一行。
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.
對于每個視圖對象,這種方法是可定制的??梢栽谶\行時基于一個特定視圖對象預(yù)期的行數(shù)決定使用什么值進行設(shè)定。
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);
測試結(jié)果:
fetchedRowCount is 0
rowCount is 1001
rowCountInRange is 1
estimatedRowCount is 1001
rangeSize is 1
fetchSize is 1
employerCount is 0
allRowLength is 1
問題:
實際數(shù)據(jù)庫的記錄數(shù)是:5 9924,distinct掉重復(fù)的person_id后,記錄數(shù)是3 1113。
在頁面上會報出如下警告:警告 - 查詢已超出 1000 行。可能存在更多的行,請限制查詢。
不知道是否與此設(shè)置有關(guān)。
關(guān)于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。如果這個方法在行集還沒有被執(zhí)行的時候被調(diào)用,將隱式調(diào)用executeQuery。
If the current row designation is to change, ViewRowImpl.validate() is called to validate the current row.
如果當前行的指定被改變,ViewRowImpl.validate()被調(diào)用驗證當前行。
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.
行集在第一行之前,和最后一行之后都有一個“空位”。當行集被執(zhí)行時,迭代器定位在第一行之前的空位。如果next()在一個新執(zhí)行的行上被調(diào)用,第一行將返回。
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()被調(diào)用時,如果迭代器在范圍的最后一行,RowSetListener.rangeScrolled()被調(diào)用發(fā)送ScrollEvent到注冊的RowSetListeners。
When successful, this method fires a NavigationEvent to registered RowSetListeners, by callingRowSetListener.navigated(). The row returned is designated as the current row.
當成功的時候,該方法通過調(diào)用RowSetListener.navigated()觸發(fā)NavigationEvent。返回的行被標志為當前行。
分享名稱:關(guān)于VO讀取記錄
轉(zhuǎn)載來源:http://www.dlmjj.cn/article/jieisp.html