@@ -59,6 +59,7 @@ public class JdbcQueryCreator extends RelationalQueryCreator<ParametrizedQuery>
5959 private final ReturnedType returnedType ;
6060 private final Optional <Lock > lockMode ;
6161 private final StatementFactory statementFactory ;
62+ private final boolean isScrollQuery ;
6263
6364 /**
6465 * Creates new instance of this class with the given {@link PartTree}, {@link JdbcConverter}, {@link Dialect},
@@ -73,15 +74,15 @@ public class JdbcQueryCreator extends RelationalQueryCreator<ParametrizedQuery>
7374 * @param isSliceQuery flag denoting if the query returns a {@link org.springframework.data.domain.Slice}.
7475 * @param returnedType the {@link ReturnedType} to be returned by the query. Must not be {@literal null}.
7576 * @deprecated use
76- * {@link JdbcQueryCreator#JdbcQueryCreator(RelationalMappingContext, PartTree, JdbcConverter, Dialect, RelationalEntityMetadata, RelationalParameterAccessor, boolean, ReturnedType, Optional, SqlGeneratorSource)}
77+ * {@link JdbcQueryCreator#JdbcQueryCreator(RelationalMappingContext, PartTree, JdbcConverter, Dialect, RelationalEntityMetadata, RelationalParameterAccessor, boolean, ReturnedType, Optional, SqlGeneratorSource, boolean )}
7778 * instead.
7879 */
7980 @ Deprecated (since = "4.0" , forRemoval = true )
8081 JdbcQueryCreator (RelationalMappingContext context , PartTree tree , JdbcConverter converter , Dialect dialect ,
81- RelationalEntityMetadata <?> entityMetadata , RelationalParameterAccessor accessor , boolean isSliceQuery ,
82- ReturnedType returnedType , Optional <Lock > lockMode ) {
82+ RelationalEntityMetadata <?> entityMetadata , RelationalParameterAccessor accessor , boolean isSliceQuery ,
83+ ReturnedType returnedType , Optional <Lock > lockMode , boolean isScrollQuery ) {
8384 this (context , tree , converter , dialect , entityMetadata , accessor , isSliceQuery , returnedType , lockMode ,
84- new SqlGeneratorSource (context , converter , dialect ));
85+ new SqlGeneratorSource (context , converter , dialect ), isScrollQuery );
8586 }
8687
8788 /**
@@ -96,32 +97,33 @@ public class JdbcQueryCreator extends RelationalQueryCreator<ParametrizedQuery>
9697 * @since 4.0
9798 */
9899 public JdbcQueryCreator (PartTree tree , JdbcConverter converter , Dialect dialect , JdbcQueryMethod queryMethod ,
99- RelationalParameterAccessor accessor , ReturnedType returnedType ) {
100+ RelationalParameterAccessor accessor , ReturnedType returnedType ) {
100101 this (converter .getMappingContext (), tree , converter , dialect , queryMethod .getEntityInformation (), accessor ,
101102 queryMethod .isSliceQuery (), returnedType , queryMethod .lookupLockAnnotation (),
102- new SqlGeneratorSource (converter , dialect ));
103+ new SqlGeneratorSource (converter , dialect ), queryMethod . isScrollQuery () );
103104 }
104105
105106 /**
106107 * Creates new instance of this class with the given {@link PartTree}, {@link JdbcConverter}, {@link Dialect},
107108 * {@link RelationalEntityMetadata} and {@link RelationalParameterAccessor}.
108109 *
109- * @param context the mapping context. Must not be {@literal null}.
110- * @param tree part tree, must not be {@literal null}.
111- * @param converter must not be {@literal null}.
112- * @param dialect must not be {@literal null}.
113- * @param entityMetadata relational entity metadata, must not be {@literal null}.
114- * @param accessor parameter metadata provider, must not be {@literal null}.
115- * @param isSliceQuery flag denoting if the query returns a {@link org.springframework.data.domain.Slice}.
116- * @param returnedType the {@link ReturnedType} to be returned by the query. Must not be {@literal null}.
117- * @param lockMode lock mode to be used for the query.
110+ * @param context the mapping context. Must not be {@literal null}.
111+ * @param tree part tree, must not be {@literal null}.
112+ * @param converter must not be {@literal null}.
113+ * @param dialect must not be {@literal null}.
114+ * @param entityMetadata relational entity metadata, must not be {@literal null}.
115+ * @param accessor parameter metadata provider, must not be {@literal null}.
116+ * @param isSliceQuery flag denoting if the query returns a {@link org.springframework.data.domain.Slice}.
117+ * @param returnedType the {@link ReturnedType} to be returned by the query. Must not be {@literal null}.
118+ * @param lockMode lock mode to be used for the query.
118119 * @param sqlGeneratorSource the source providing SqlGenerator instances for generating SQL. Must not be
119- * {@literal null}
120+ * {@literal null}
121+ * @param isScrollQuery
120122 * @since 4.0
121123 */
122124 public JdbcQueryCreator (RelationalMappingContext context , PartTree tree , JdbcConverter converter , Dialect dialect ,
123- RelationalEntityMetadata <?> entityMetadata , RelationalParameterAccessor accessor , boolean isSliceQuery ,
124- ReturnedType returnedType , Optional <Lock > lockMode , SqlGeneratorSource sqlGeneratorSource ) {
125+ RelationalEntityMetadata <?> entityMetadata , RelationalParameterAccessor accessor , boolean isSliceQuery ,
126+ ReturnedType returnedType , Optional <Lock > lockMode , SqlGeneratorSource sqlGeneratorSource , boolean isScrollQuery ) {
125127 super (tree , accessor );
126128
127129 Assert .notNull (converter , "JdbcConverter must not be null" );
@@ -139,6 +141,7 @@ public JdbcQueryCreator(RelationalMappingContext context, PartTree tree, JdbcCon
139141 this .returnedType = returnedType ;
140142 this .lockMode = lockMode ;
141143 this .statementFactory = new StatementFactory (converter , dialect );
144+ this .isScrollQuery = isScrollQuery ;
142145 }
143146
144147 StatementFactory getStatementFactory () {
@@ -205,6 +208,8 @@ protected ParametrizedQuery complete(@Nullable Criteria criteria, Sort sort) {
205208
206209 selection .page (accessor .getPageable ()).filter (criteria ).orderBy (sort );
207210
211+ selection .scrollPosition (accessor .getScrollPosition ());
212+
208213 if (this .lockMode .isPresent ()) {
209214 selection .lock (this .lockMode .get ().value ());
210215 }
@@ -225,6 +230,8 @@ StatementFactory.SelectionBuilder getSelection(RelationalPersistentEntity<?> ent
225230
226231 if (isSliceQuery ) {
227232 selection = statementFactory .slice (entity );
233+ } else if (isScrollQuery ) {
234+ selection = statementFactory .scroll (entity );
228235 } else {
229236 selection = statementFactory .select (entity );
230237 }
0 commit comments