Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

About VO read record

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

About VO read record

GetRowCount ()

Counts the total number of rows in this row set.

Calculate the total number of rows in this rowset

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.

This method fetches all rows from the view object by executing a query for the view object, and then calls next () until the last row is called. Therefore, this method is slow because it iterates through the view object one record at a time.

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

If you are working on a lot of lines, or if your application needs a quick response, use getEstimatedRowCount to get a faster number.

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

The following code uses getRowCount () to create separate iterators for cardinality and even rows.

/ / 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.

The actual number of rows within the calculated range

GetRowCountInRange (): int

Gets the size of the current RowSet's range

Gets the range size of the current RowSet (recordset).

GetFetchedRowCount (): int

Counts the number of rows fetched from the JDBC result set.

Calculates the number of rows fetched from the JDBC result set.

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.

This method is used to determine whether the view object reads all rows from the cursor. For example, getEstimatedRowCount returns the equal amount of count (*) on the view object. The getFetchedRowCount () method returns only the number of rows that have been crawled. If the value returned by getFetchedRowCount () is less than getEstimatedRowCount (), the view object does not read all the rows from the cursor.

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 ().

Note: however, this method may not be as accurate as 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.

Get the pre-fetched size of the row

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.

The framework will use this value to set the JDBC session crawl size. Note that the size of the crawl affects performance. A larger grab size is more expensive in terms of memory usage than a small grab size. The default crawl size is one row.

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

If the value of setFetchMode is FETCH_ALL, setFetchSize is ignored.

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.

This approach is customizable for each view object. You can decide what value to use at run time based on the expected number of rows for a particular view object.

GetRangeSize ()

Returns the range size of the iterator.

Gets the range size of the iterator.

Test the code:

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)

Test results:

FetchedRowCount is 0

RowCount is 1001

RowCountInRange is 1

EstimatedRowCount is 1001

RangeSize is 1

FetchSize is 1

EmployerCount is 0

AllRowLength is 1

Question:

The number of records in the actual database is 5 9924. After deleting the duplicate person_id, the number of records is 3 1113.

The following warning is reported on the page: warning-the query has exceeded 1000 lines. There may be more rows, please restrict the query.

I don't know if it has anything to do with this setting.

About the next () method:

Next (): ROW

Gets the next row in the iterator.

Get the next line 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.

This method delegates to the default RowSetIterator. If this method is called before the rowset has been executed, executeQuery is implicitly called.

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

If the assignment of the current line is changed, ViewRowImpl.validate () is called to validate the current line.

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.

The rowset has a "space" before the first row and after the last row. When the rowset is executed, the iterator is positioned in the space before the first row. If next () is called on a newly executed line, the first line will return.

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.

When next () is called, RowSetListener.rangeScrolled () is called to send ScrollEvent to the registered RowSetListeners if the iterator is on the last line of the range.

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

When successful, the method triggers NavigationEvent by calling RowSetListener.navigated (). The returned row is marked as the current row.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report