FileDocCategorySizeDatePackage
AbstractScrollableResults.javaAPI DocHibernate 3.2.57508Thu Jun 07 13:22:50 BST 2007org.hibernate.impl

AbstractScrollableResults

public abstract class AbstractScrollableResults extends Object implements org.hibernate.ScrollableResults
Implementation of the ScrollableResults interface
author
Steve Ebersole

Fields Summary
private static final Log
log
private final ResultSet
resultSet
private final PreparedStatement
ps
private final org.hibernate.engine.SessionImplementor
session
private final org.hibernate.loader.Loader
loader
private final org.hibernate.engine.QueryParameters
queryParameters
private final org.hibernate.type.Type[]
types
private org.hibernate.hql.HolderInstantiator
holderInstantiator
Constructors Summary
public AbstractScrollableResults(ResultSet rs, PreparedStatement ps, org.hibernate.engine.SessionImplementor sess, org.hibernate.loader.Loader loader, org.hibernate.engine.QueryParameters queryParameters, org.hibernate.type.Type[] types, org.hibernate.hql.HolderInstantiator holderInstantiator)


	 
	         
	         
	         
			 
			 
	         
	            
		this.resultSet=rs;
		this.ps=ps;
		this.session = sess;
		this.loader = loader;
		this.queryParameters = queryParameters;
		this.types = types;
		this.holderInstantiator = holderInstantiator!=null && holderInstantiator.isRequired()
		        ? holderInstantiator 
		        : null;
	
Methods Summary
protected voidafterScrollOperation()

		session.afterScrollOperation();
	
public final voidclose()

		try {
			// not absolutely necessary, but does help with aggressive release
			session.getBatcher().closeQueryStatement( ps, resultSet );
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					session.getFactory().getSQLExceptionConverter(),
					sqle,
					"could not close results"
				);
		}
		finally {
			try {
				session.getPersistenceContext().getLoadContexts().cleanup( resultSet );
			}
			catch( Throwable ignore ) {
				// ignore this error for now
				log.trace( "exception trying to cleanup load context : " + ignore.getMessage() );
			}
		}
	
public final java.lang.Object[]get()

		return getCurrentRow();
	
public final java.lang.Objectget(int col)

		return getCurrentRow()[col];
	
public final java.math.BigDecimalgetBigDecimal(int col)

		return (BigDecimal) getFinal(col, Hibernate.BIG_DECIMAL);
	
public final java.math.BigIntegergetBigInteger(int col)

		return (BigInteger) getFinal(col, Hibernate.BIG_INTEGER);
	
public final byte[]getBinary(int col)

		return (byte[]) getFinal(col, Hibernate.BINARY);
	
public final java.sql.BlobgetBlob(int col)

		return (Blob) getNonFinal(col, Hibernate.BLOB);
	
public final java.lang.BooleangetBoolean(int col)

		return (Boolean) getFinal(col, Hibernate.BOOLEAN);
	
public final java.lang.BytegetByte(int col)

		return (Byte) getFinal(col, Hibernate.BYTE);
	
public final java.util.CalendargetCalendar(int col)

		return (Calendar) getNonFinal(col, Hibernate.CALENDAR);
	
public final java.lang.CharactergetCharacter(int col)

		return (Character) getFinal(col, Hibernate.CHARACTER);
	
public final java.sql.ClobgetClob(int col)

		return (Clob) getNonFinal(col, Hibernate.CLOB);
	
protected abstract java.lang.Object[]getCurrentRow()

public final java.util.DategetDate(int col)

		return (Date) getNonFinal(col, Hibernate.TIMESTAMP);
	
public final java.lang.DoublegetDouble(int col)

		return (Double) getFinal(col, Hibernate.DOUBLE);
	
protected final java.lang.ObjectgetFinal(int col, org.hibernate.type.Type returnType)
Check that the requested type is compatible with the result type, and return the column value. This version makes sure the the classes are identical.

param
col the column
param
returnType a "final" type

		if ( holderInstantiator!=null ) {
			throw new HibernateException("query specifies a holder class");
		}
		
		if ( returnType.getReturnedClass()==types[col].getReturnedClass() ) {
			return get(col);
		}
		else {
			return throwInvalidColumnTypeException(col, types[col], returnType);
		}
	
public final java.lang.FloatgetFloat(int col)

		return (Float) getFinal(col, Hibernate.FLOAT);
	
protected org.hibernate.hql.HolderInstantiatorgetHolderInstantiator()

		return holderInstantiator;
	
public final java.lang.IntegergetInteger(int col)

		return (Integer) getFinal(col, Hibernate.INTEGER);
	
protected org.hibernate.loader.LoadergetLoader()

		return loader;
	
public final java.util.LocalegetLocale(int col)

		return (Locale) getFinal(col, Hibernate.LOCALE);
	
public final java.lang.LonggetLong(int col)

		return (Long) getFinal(col, Hibernate.LONG);
	
protected final java.lang.ObjectgetNonFinal(int col, org.hibernate.type.Type returnType)
Check that the requested type is compatible with the result type, and return the column value. This version makes sure the the classes are "assignable".

param
col the column
param
returnType any type

		if ( holderInstantiator!=null ) {
			throw new HibernateException("query specifies a holder class");
		}
		
		if ( returnType.getReturnedClass().isAssignableFrom( types[col].getReturnedClass() ) ) {
			return get(col);
		}
		else {
			return throwInvalidColumnTypeException(col, types[col], returnType);
		}
	
protected java.sql.PreparedStatementgetPs()

		return ps;
	
protected org.hibernate.engine.QueryParametersgetQueryParameters()

		return queryParameters;
	
protected java.sql.ResultSetgetResultSet()

		return resultSet;
	
protected org.hibernate.engine.SessionImplementorgetSession()

		return session;
	
public final java.lang.ShortgetShort(int col)

		return (Short) getFinal(col, Hibernate.SHORT);
	
public final java.lang.StringgetString(int col)

		return (String) getFinal(col, Hibernate.STRING);
	
public final java.lang.StringgetText(int col)

		return (String) getFinal(col, Hibernate.TEXT);
	
public final java.util.TimeZonegetTimeZone(int col)

		return (TimeZone) getNonFinal(col, Hibernate.TIMEZONE);
	
public final org.hibernate.type.TypegetType(int i)

		return types[i];
	
protected org.hibernate.type.Type[]getTypes()

		return types;
	
private java.lang.ObjectthrowInvalidColumnTypeException(int i, org.hibernate.type.Type type, org.hibernate.type.Type returnType)

		throw new HibernateException( 
				"incompatible column types: " + 
				type.getName() + 
				", " + 
				returnType.getName() 
		);