QueryDSl, Sorting OneToMany duplciates

33 views
Skip to first unread message

Aderito Baptista

unread,
Aug 5, 2016, 7:29:56 AM8/5/16
to Querydsl
Hi all,


I have the following scenario:

- An entity A that has a OneToMany relationship to another entity Entity B.
- A repository that extends QueryDslPredicateExecutor<EntityA>, to have access to paging and sorting out of the box. It returns me instances of EntityA.
     Page<T> findAll(Predicate var1, Pageable var2);

- I'm applying a Sort in a property/column of Entity B. 

I'm struggling with the fact that it's returning me duplicates of EntityA, since the relation with B is OneToMany. I have researched and it seems to not be possible to distinct the result in the predicate. 

Is there a way where I can achieve this, and still be able to take advantage of Paging and Sorting?

Many thanks.
 

timowest

unread,
Aug 10, 2016, 2:41:26 PM8/10/16
to Querydsl
If you need distinct results, you will need to constrain the oneToMany join to link only one row
Reply all
Reply to author
Forward
0 new messages