public IteratorImpl( ResultSet rs, PreparedStatement ps, EventSource sess, Type[] types, String[][] columnNames, HolderInstantiator holderInstantiator) throws HibernateException, SQLException { this.rs=rs; this.ps=ps; this.session = sess; this.types = types; this.names = columnNames; this.holderInstantiator = holderInstantiator; single = types.length==1; postNext(); }
/** * Return the query results as an iterator */ public Iterator iterate(QueryParameters queryParameters, SessionImplementor session) throws HibernateException { boolean stats = session.getFactory().getStatistics().isStatisticsEnabled(); long startTime = 0; if ( stats ) startTime = System.currentTimeMillis(); try { PreparedStatement st = prepareQueryStatement( queryParameters, false, session ); ResultSet rs = getResultSet( st, false, queryParameters.getRowSelection(), session ); HolderInstantiator hi = new HolderInstantiator(holderConstructor, false, false, null); Iterator result = new IteratorImpl( rs, st, session, returnTypes, getColumnNames(), hi ); if ( stats ) { session.getFactory().getStatisticsImplementor().queryExecuted( "HQL: " + queryString, 0, System.currentTimeMillis() - startTime ); } return result; } catch ( SQLException sqle ) { throw JDBCExceptionHelper.convert( getFactory().getSQLExceptionConverter(), sqle, "could not execute query using iterate", getSQLString() ); } }
private void postNext() throws HibernateException, SQLException { this.hasNext = rs.next(); if (!hasNext) { log.debug("exhausted results"); close(); } else { log.debug("retrieving next results"); boolean isHolder = holderInstantiator.isRequired(); if ( single && !isHolder ) { nextResult = types[0].nullSafeGet( rs, names[0], session, null ); } else { Object[] nextResults = new Object[types.length]; for (int i=0; i<types.length; i++) { nextResults[i] = types[i].nullSafeGet( rs, names[i], session, null ); } if (isHolder) { nextResult = holderInstantiator.instantiate(nextResults); } else { nextResult = nextResults; } } } }
final Iterator result = new IteratorImpl( rs, st,
private void postNext() throws HibernateException, SQLException { this.hasNext = rs.next(); if (!hasNext) { log.debug("exhausted results"); close(); } else { log.debug("retrieving next results"); boolean isHolder = holderInstantiator.isRequired(); if ( single && !isHolder ) { nextResult = types[0].nullSafeGet( rs, names[0], sess, null ); } else { Object[] nextResults = new Object[types.length]; for (int i=0; i<types.length; i++) { nextResults[i] = types[i].nullSafeGet( rs, names[i], sess, null ); } if (isHolder) { nextResult = holderInstantiator.instantiate(nextResults); } else { nextResult = nextResults; } } } }
public IteratorImpl( ResultSet rs, PreparedStatement ps, SessionImplementor sess, Type[] types, String[][] columnNames, HolderInstantiator holderInstantiator) throws HibernateException, SQLException { this.rs=rs; this.ps=ps; this.sess = sess; this.types = types; this.names = columnNames; this.holderInstantiator = holderInstantiator; single = types.length==1; postNext(); }
ResultSet rs = getResultSet( st, queryParameters.hasAutoDiscoverScalarTypes(), false, queryParameters.getRowSelection(), session ); HolderInstantiator hi = HolderInstantiator.createClassicHolderInstantiator(holderConstructor, queryParameters.getResultTransformer()); Iterator result = new IteratorImpl( rs, st, session, returnTypes, getColumnNames(), hi );
public Object next() { if ( !hasNext ) throw new NoSuchElementException("No more results"); try { currentResult = nextResult; postNext(); log.debug("returning current results"); return currentResult; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( sess.getFactory().getSQLExceptionConverter(), sqle, "could not get next iterator result" ); } }
final Iterator result = new IteratorImpl( rs, st,
public Object next() { if ( !hasNext ) throw new NoSuchElementException("No more results"); try { currentResult = nextResult; postNext(); log.debug("returning current results"); return currentResult; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( session.getFactory().getSQLExceptionConverter(), sqle, "could not get next iterator result" ); } }