Code example for SessionImplementor

Methods: afterScrollOperationgetFactorygetPersistenceContext

0
 
	/** 
	 * @see org.hibernate.ScrollableResults#first() 
	 */ 
	public boolean first() throws HibernateException {
		try { 
			boolean result = getResultSet().first();
			prepareCurrentRow(result);
			return result;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"could not advance using first()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#last() 
	 */ 
	public boolean last() throws HibernateException {
		try { 
			boolean result = getResultSet().last();
			prepareCurrentRow(result);
			return result;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"could not advance using last()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#next() 
	 */ 
	public boolean next() throws HibernateException {
		try { 
			boolean result = getResultSet().next();
			prepareCurrentRow(result);
			return result;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"could not advance using next()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#previous() 
	 */ 
	public boolean previous() throws HibernateException {
		try { 
			boolean result = getResultSet().previous();
			prepareCurrentRow(result);
			return result;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"could not advance using previous()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#afterLast() 
	 */ 
	public void afterLast() throws HibernateException {
		try { 
			getResultSet().afterLast();
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"exception calling afterLast()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#beforeFirst() 
	 */ 
	public void beforeFirst() throws HibernateException {
		try { 
			getResultSet().beforeFirst();
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"exception calling beforeFirst()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#isFirst() 
	 */ 
	public boolean isFirst() throws HibernateException {
		try { 
			return getResultSet().isFirst();
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"exception calling isFirst()" 
				); 
		} 
	} 
 
	/** 
	 * @see org.hibernate.ScrollableResults#isLast() 
	 */ 
	public boolean isLast() throws HibernateException {
		try { 
			return getResultSet().isLast();
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"exception calling isLast()" 
				); 
		} 
	} 
 
	public int getRowNumber() throws HibernateException {
		try { 
			return getResultSet().getRow()-1;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"exception calling getRow()" 
				); 
		} 
	} 
 
	public boolean setRowNumber(int rowNumber) throws HibernateException {
		if (rowNumber>=0) rowNumber++;
		try { 
			boolean result = getResultSet().absolute(rowNumber);
			prepareCurrentRow(result);
			return result;
		} 
		catch (SQLException sqle) {
			throw getSession().getFactory().getSQLExceptionHelper().convert(
					sqle,
					"could not advance using absolute()" 
				); 
		} 
	} 
 
	private void prepareCurrentRow(boolean underlyingScrollSuccessful) 
	throws HibernateException {
		 
		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(); 
	} 
 
} 
Experience pair programming with AI  Get Codota for Java