Hello everyone,
Does anyone know if CoroutinesCrudRepository supports pagination?
j
Johan
01/27/2024, 9:34 AM
No, but you can create an query which returns a flow. With offset and limit as params
b
Bogdan Costea
01/27/2024, 10:35 AM
Thanks Johan, and talking about the total number of pages each time should I execute a count query ?
j
Johan
01/27/2024, 10:39 AM
I haven't done it in a while but you can use 2 different queries for that. This answer on SO is an example of doing it as 1 query, haven't tried that
https://stackoverflow.com/a/28888696
Johan
01/27/2024, 10:42 AM
If you try the non reactive pagination in an test and enable sql logging you can see how spring solves it. I would guess they do 2 different queries but not sure
b
Bogdan Costea
01/27/2024, 2:54 PM
Hmm nice approach, for now I made the pagination with two queries. I was also planning to check what’s behind the non reactive pagination but I’m a bit afraid of what queries are generated.
Bogdan Costea
01/27/2024, 2:57 PM
Also I introduced R2dbcEntityTemplate to build dynamic queries, have you used it before? If so what’s your opinion about it?
j
Johan
01/29/2024, 7:55 AM
Have used similar (non-reactive) many years ago. I would guess both alternatives work well 🙂 It's mostly about preferences