assertNotNull(s
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
.setString( "desc", "root%" )
.uniqueResult() );
ScrollableResults results = s
.createQuery( "from Animal a left join fetch a.offspring where a.description like :desc order by a.id" )
.setString( "desc", "root%" )
.scroll();
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertFalse( results.previous() );
assertTrue( results.next() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.next() );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertTrue( results.previous() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.previous() );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertTrue( results.next() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
results.beforeFirst();
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertFalse( results.previous() );
assertTrue( results.first() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.next() );
results.afterLast();
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertFalse( results.next() );
assertTrue( results.last() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.next() );
assertTrue( results.first() );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
for ( int i=1; i<3; i++ ) {
assertTrue( results.setRowNumber( 1 ) );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.scroll( i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertTrue( results.setRowNumber( 1 ) );
assertTrue( results.isFirst() );
assertTrue( results.isLast() );
assertFalse( results.scroll( - i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
if ( i != 1 ) {
assertFalse( results.setRowNumber( i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
assertFalse( results.setRowNumber( - i ) );
assertFalse( results.isFirst() );
assertFalse( results.isLast() );
}
}
txn.commit();
s.close();