Hello everyone, Does anyone know if CoroutinesCrud...
# spring
b
Hello everyone, Does anyone know if CoroutinesCrudRepository supports pagination?
j
No, but you can create an query which returns a flow. With offset and limit as params
b
Thanks Johan, and talking about the total number of pages each time should I execute a count query ?
j
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
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
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.
Also I introduced R2dbcEntityTemplate to build dynamic queries, have you used it before? If so what’s your opinion about it?
j
Have used similar (non-reactive) many years ago. I would guess both alternatives work well 🙂 It's mostly about preferences
👍 1