How to page when mapping a value from OneToMany #1931
Unanswered
EvandoBlanco
asked this question in
Q&A
Replies: 2 comments
-
Doing some work, I see that this is the ID query caused by the join. Does this prevent properly paging when mapping a OneToMany? |
Beta Was this translation helpful? Give feedback.
0 replies
-
You're "joining" over a collection @EntityView(Cat.class)
public interface CatSimpleView {
@IdMapping
Long getId();
String getName();
@Mapping("kittens.name")
Set<String> getKittenNames();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to use an entity view to represent a list compiled from several related entities. When paging, mapping a value from a
OneToMany
field results in where clause ofWHERE entity.id in (<subquery>)
. This results in more views being returned than I would expect: i.e. one for every entity within the limit + related entity. Is there another pattern I should be using?In the case below, the resulting query will create a views for every kitten of the first 10 cats.
To recreate simply adjust the
CatSimpleView
from the sample as follows:Run a query with:
Results in:
Beta Was this translation helpful? Give feedback.
All reactions