I have this query:
"select distinct d from Dance d " +
"inner join d.meisterschaftDances ms " +
"inner join ms.danceRegistrations dr " +
"inner join dr.user u " +
"where (u.id = :userId " +
"or d.user.id = :userId) " +
"AND ms.meisterschaft.open = FALSE " +
"order by ms.meisterschaft.organizer.id, " +
"d.discipline, d.age, d.category, " +
"d.class"
The logic would be perfect for me but as we know distinct is not so easy with order by.
I get the same dance several times because the inner join to meisterschaftDances can have several references.
Sadly I dont know how to rewrite my query in such a way that it is working. Can somebody show me an example which would work. Thanks