Author: gbadner
Date: 2007-08-29 19:00:10 -0400 (Wed, 29 Aug 2007)
New Revision: 13961
Modified:
core/branches/Branch_3_2/src/org/hibernate/impl/IteratorImpl.java
Log:
HHH-2728 : session.clear() while retrieving objects via an iterator fix that should work
for all dialects
Modified: core/branches/Branch_3_2/src/org/hibernate/impl/IteratorImpl.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/impl/IteratorImpl.java 2007-08-29 20:59:12
UTC (rev 13960)
+++ core/branches/Branch_3_2/src/org/hibernate/impl/IteratorImpl.java 2007-08-29 23:00:10
UTC (rev 13961)
@@ -54,12 +54,7 @@
single = types.length==1;
- // rs.isBeforeFirst() will return false if rs contains no rows
- hasNext = this.rs.isBeforeFirst();
- if ( !hasNext ) {
- log.debug("ResultSet contains no rows");
- close();
- }
+ postNext();
}
public void close() throws JDBCException {
@@ -92,11 +87,15 @@
}
private void postNext() throws SQLException {
- this.hasNext = !rs.isLast();
+ log.debug("attempting to retrieve next results");
+ this.hasNext = rs.next();
if (!hasNext) {
log.debug("exhausted results");
close();
}
+ else {
+ log.debug("retrieved next results");
+ }
}
public boolean hasNext() {
@@ -106,10 +105,9 @@
public Object next() throws HibernateException {
if ( !hasNext ) throw new NoSuchElementException("No more results");
try {
- log.debug("retrieving next results");
- rs.next();
boolean isHolder = holderInstantiator.isRequired();
+ log.debug("assembling results");
if ( single && !isHolder ) {
currentResult = types[0].nullSafeGet( rs, names[0], session, null );
}
Show replies by date