User in front selecting a filter (Lits<Phones>, Lits<Students>, Name, how to sort them (OR / AND)). I need to filter it.
I solved this problem by StringBuilder and loops in Lists (HQL), but i need to change it to Criteria.
The final query must be looks like:
select distinct entity from Event entity
left join entity.phones ph
left join entity.students st
where
(lower(entity.name) like "word") and
(entity.id = 1 or entity.id = 2) and
(ph.id = 1 or ph.id = 2) or
(st.id = 1 or st.id = 2 or st.id = 3 and st.id = 4)
order by entity.updated desc