I decided to remake the request for the spring jpa specification, I just can’t beat the subqueries in order to implement them on the specification, there is the following query:
SELECT DISTINCT a FROM A a, B b FETCH JOIN a.fieldC FETCH JOIN a.fieldD WHERE a.field=:field and (SELECT COUNT(b) FROM B b WHERE baid=a.id and b.status=STATUS) = 0 and baid=a.id and (SELECT COUNT(b) FROM B b WHERE baid=a.id and b.field.id=1) > 0 and a.date>:date order by a.fieldToOrder desc; Everything turns out to be done, but as soon as it comes to two subqueries in the query, nothing comes out of me. Can anyone have any ideas? thank