HHH-13556 Tests doing dynamic fetch scrolling a collection fail on DB2

This commit is contained in:
Andrea Boriero 2019-08-13 21:01:12 +01:00 committed by gbadner
parent f2f788c03d
commit 2aee5a930d
2 changed files with 25 additions and 2 deletions

View File

@ -24,6 +24,7 @@ import org.hibernate.StatelessSession;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.query.Query;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
@ -73,7 +74,17 @@ public class StatelessQueryScrollingTest extends BaseNonConfigCoreFunctionalTest
try {
final Query query = statelessSession.createQuery( "select p from Producer p join fetch p.products" );
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
Producer producer = (Producer) scrollableResults.get( 0 );
assertTrue( Hibernate.isInitialized( producer ) );

View File

@ -18,6 +18,7 @@ import org.hibernate.StatelessSession;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.hibernate.cfg.Configuration;
import org.hibernate.dialect.DB2Dialect;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.internal.util.StringHelper;
@ -224,7 +225,18 @@ public class StatelessSessionFetchingTest extends BaseCoreFunctionalTestCase {
ss.beginTransaction();
final Query query = ss.createQuery( "select p from Producer p join fetch p.products" );
final ScrollableResults scrollableResults = query.scroll(ScrollMode.FORWARD_ONLY);
ScrollableResults scrollableResults = null;
if ( getDialect() instanceof DB2Dialect ) {
/*
FetchingScrollableResultsImp#next() in order to check if the ResultSet is empty calls ResultSet#isBeforeFirst()
but the support for ResultSet#isBeforeFirst() is optional for ResultSets with a result
set type of TYPE_FORWARD_ONLY and db2 does not support it.
*/
scrollableResults = query.scroll( ScrollMode.SCROLL_INSENSITIVE );
}
else {
scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY );
}
while ( scrollableResults.next() ) {
Producer producer = (Producer) scrollableResults.get( 0 );
assertTrue( Hibernate.isInitialized( producer ) );