Methods Summary |
---|
private void | checkResult(Animal animal)
if ( "root-1".equals( animal.getDescription() ) ) {
assertEquals( "root-1 did not contain both children", 2, animal.getOffspring().size() );
}
else if ( "root-2".equals( animal.getDescription() ) ) {
assertEquals( "root-2 did not contain zero children", 0, animal.getOffspring().size() );
}
|
public java.lang.String[] | getMappings()
return new String[] { "hql/Animal.hbm.xml" };
|
public static junit.framework.Test | suite()
return new FunctionalTestClassTestSuite( ScrollableCollectionFetchingTest.class );
|
public void | testScrollingJoinFetchesForward()
if ( ! supportsResultSetPositionQueryMethodsOnForwardOnlyCursor() ) {
return;
}
TestData data = new TestData();
data.prepare();
Session s = openSession();
Transaction txn = s.beginTransaction();
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( ScrollMode.FORWARD_ONLY );
int counter = 0;
while ( results.next() ) {
counter++;
Animal animal = ( Animal ) results.get( 0 );
checkResult( animal );
}
assertEquals( "unexpected result count", 2, counter );
txn.commit();
s.close();
data.cleanup();
|
public void | testScrollingJoinFetchesPositioning()
TestData data = new TestData();
data.prepare();
Session s = openSession();
Transaction txn = s.beginTransaction();
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();
results.first();
Animal animal = ( Animal ) results.get( 0 );
assertEquals( "first() did not return expected row", data.root1Id, animal.getId() );
results.scroll( 1 );
animal = ( Animal ) results.get( 0 );
assertEquals( "scroll(1) did not return expected row", data.root2Id, animal.getId() );
results.scroll( -1 );
animal = ( Animal ) results.get( 0 );
assertEquals( "scroll(-1) did not return expected row", data.root1Id, animal.getId() );
results.setRowNumber( 1 );
animal = ( Animal ) results.get( 0 );
assertEquals( "setRowNumber(1) did not return expected row", data.root1Id, animal.getId() );
results.setRowNumber( 2 );
animal = ( Animal ) results.get( 0 );
assertEquals( "setRowNumber(2) did not return expected row", data.root2Id, animal.getId() );
txn.commit();
s.close();
data.cleanup();
|
public void | testScrollingJoinFetchesReverse()
TestData data = new TestData();
data.prepare();
Session s = openSession();
Transaction txn = s.beginTransaction();
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();
results.afterLast();
int counter = 0;
while ( results.previous() ) {
counter++;
Animal animal = ( Animal ) results.get( 0 );
checkResult( animal );
}
assertEquals( "unexpected result count", 2, counter );
txn.commit();
s.close();
data.cleanup();
|
public void | testTupleReturnFails()
Session s = openSession();
Transaction txn = s.beginTransaction();
try {
s.createQuery( "select a, a.weight from Animal a inner join fetch a.offspring" ).scroll();
fail( "scroll allowed with collection fetch and reurning tuples" );
}
catch( HibernateException e ) {
// expected result...
}
txn.commit();
s.close();
|