diff --git a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/StatelessQueryScrollingTest.java b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/StatelessQueryScrollingTest.java index 1bc6da1809..2aa0d1cdf4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/StatelessQueryScrollingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/bytecode/enhancement/lazy/StatelessQueryScrollingTest.java @@ -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" ); - scrollableResults = query.scroll( ScrollMode.FORWARD_ONLY ); + 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 ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java index 01f7d0e75f..1b058e74e5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/stateless/fetching/StatelessSessionFetchingTest.java @@ -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 ) );