Skip to content

Commit

Permalink
HHH-13556 Tests doing dynamic fetch scrolling a collection fail on DB2
Browse files Browse the repository at this point in the history
(cherry picked from commit 2aee5a9)
  • Loading branch information
dreab8 authored and gbadner committed Aug 13, 2019
1 parent c7e86e9 commit a95bbdd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -73,7 +74,17 @@ public void testDynamicFetchCollectionScroll() {

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 ) );
Expand Down
Expand Up @@ -18,6 +18,7 @@
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;

Expand Down Expand Up @@ -224,7 +225,18 @@ public void testDynamicFetchCollectionScroll() {
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 ) );
Expand Down

0 comments on commit a95bbdd

Please sign in to comment.