diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 1d481498e7..263c00a081 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -1344,7 +1344,12 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); - HQLQueryPlan plan = getHQLQueryPlan( query, false ); + + HQLQueryPlan plan = queryParameters.getQueryPlan(); + if (plan == null) { + plan = getHQLQueryPlan( query, false ); + } + autoFlushIfRequired( plan.getQuerySpaces() ); dontFlushFromFind++; try {