posted 11 years ago
By looking at the query, it seems to be OK.
However can you please set setSqlEnabled property as true(in hibernate it is there, not sure about JPA) and check which query has been prepared by JPA?
Once you get simple query, you can fire on DB and check the expected behavior. If query is wrong, it means jpa query requires changes.