FileDocCategorySizeDatePackage
ScrollableResultsImpl.javaAPI DocHibernate 3.2.55996Thu Jul 14 08:12:20 BST 2005org.hibernate.impl

ScrollableResultsImpl

public class ScrollableResultsImpl extends AbstractScrollableResults implements org.hibernate.ScrollableResults
Implementation of the ScrollableResults interface
author
Gavin King

Fields Summary
private Object[]
currentRow
Constructors Summary
public ScrollableResultsImpl(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)

		super( rs, ps, sess, loader, queryParameters, types, holderInstantiator );
	
Methods Summary
public voidafterLast()

see
org.hibernate.ScrollableResults#afterLast()

		try {
			getResultSet().afterLast();
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"exception calling afterLast()"
				);
		}
	
public voidbeforeFirst()

see
org.hibernate.ScrollableResults#beforeFirst()

		try {
			getResultSet().beforeFirst();
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"exception calling beforeFirst()"
				);
		}
	
public booleanfirst()

see
org.hibernate.ScrollableResults#first()

		try {
			boolean result = getResultSet().first();
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using first()"
				);
		}
	
protected java.lang.Object[]getCurrentRow()

		return currentRow;
	
public intgetRowNumber()

		try {
			return getResultSet().getRow()-1;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"exception calling getRow()"
				);
		}
	
public booleanisFirst()

see
org.hibernate.ScrollableResults#isFirst()

		try {
			return getResultSet().isFirst();
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"exception calling isFirst()"
				);
		}
	
public booleanisLast()

see
org.hibernate.ScrollableResults#isLast()

		try {
			return getResultSet().isLast();
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"exception calling isLast()"
				);
		}
	
public booleanlast()

see
org.hibernate.ScrollableResults#last()

		try {
			boolean result = getResultSet().last();
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using last()"
				);
		}
	
public booleannext()

see
org.hibernate.ScrollableResults#next()

		try {
			boolean result = getResultSet().next();
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using next()"
				);
		}
	
private voidprepareCurrentRow(boolean underlyingScrollSuccessful)

		
		if (!underlyingScrollSuccessful) {
			currentRow = null;
			return;
		}

		Object result = getLoader().loadSingleRow(
				getResultSet(),
				getSession(),
				getQueryParameters(),
				false
		);
		if ( result != null && result.getClass().isArray() ) {
			currentRow = (Object[]) result;
		}
		else {
			currentRow = new Object[] { result };
		}

		if ( getHolderInstantiator() != null ) {
			currentRow = new Object[] { getHolderInstantiator().instantiate(currentRow) };
		}

		afterScrollOperation();
	
public booleanprevious()

see
org.hibernate.ScrollableResults#previous()

		try {
			boolean result = getResultSet().previous();
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using previous()"
				);
		}
	
public booleanscroll(int i)

see
org.hibernate.ScrollableResults#scroll(int)

		try {
			boolean result = getResultSet().relative(i);
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using scroll()"
				);
		}
	
public booleansetRowNumber(int rowNumber)

		if (rowNumber>=0) rowNumber++;
		try {
			boolean result = getResultSet().absolute(rowNumber);
			prepareCurrentRow(result);
			return result;
		}
		catch (SQLException sqle) {
			throw JDBCExceptionHelper.convert(
					getSession().getFactory().getSQLExceptionConverter(),
					sqle,
					"could not advance using absolute()"
				);
		}