From 09127bf1c36cbe9a8e90f17508444d2565b95878 Mon Sep 17 00:00:00 2001 From: reda-alaoui Date: Sun, 10 May 2015 20:47:27 +0200 Subject: [PATCH] HHH-9784 Scroll method does not support provided HQLQueryPlan --- .../src/main/java/org/hibernate/internal/SessionImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 {