Skip to content

Commit 42fe0d8

Browse files
committed
Pagination.
1 parent 857e44f commit 42fe0d8

File tree

6 files changed

+370
-219
lines changed

6 files changed

+370
-219
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/aot/AotQueries.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import java.util.LinkedHashMap;
1919
import java.util.Map;
2020

21+
import org.jspecify.annotations.Nullable;
22+
2123
import org.springframework.data.repository.aot.generate.QueryMetadata;
2224

2325
/**
@@ -26,10 +28,27 @@
2628
* @author Mark Paluch
2729
* @since 4.0
2830
*/
29-
record AotQueries(AotQuery result) {
31+
record AotQueries(AotQuery result, @Nullable AotQuery count) {
3032

33+
/**
34+
* Factory method to create an {@link AotQueries} instance with a single query.
35+
*
36+
* @param query
37+
* @return
38+
*/
3139
public static AotQueries create(AotQuery query) {
32-
return new AotQueries(query);
40+
return new AotQueries(query, null);
41+
}
42+
43+
/**
44+
* Factory method to create an {@link AotQueries} instance with an entity- and a count query.
45+
*
46+
* @param query
47+
* @param count
48+
* @return
49+
*/
50+
public static AotQueries create(AotQuery query, AotQuery count) {
51+
return new AotQueries(query, count);
3352
}
3453

3554
public QueryMetadata toMetadata() {
@@ -54,6 +73,14 @@ public Map<String, Object> serialize() {
5473
serialized.put("name", nsq.getQueryName());
5574
}
5675

76+
if (count() instanceof StringAotQuery sq) {
77+
serialized.put("count-query", sq.getQueryString());
78+
}
79+
80+
if (count() instanceof StringAotQuery.NamedStringAotQuery nsq) {
81+
serialized.put("count-name", nsq.getQueryName());
82+
}
83+
5784
return serialized;
5885
}
5986

0 commit comments

Comments
 (0)