Java – spring data: can I include subqueries in query annotations?
•
Java
I wonder if subqueries (org. Springframework. Data. JPA. Repository. Query;) can be used in the @ query annotation
I get querysyntaxexception on the first sub query parentesis
This is my inquiry
@Query(value="select c1 from ComplaintModel c1," + "(select c2.id,min(cb.termDate) minDate from ComplaintModel c2 " + "join c2.complaintBullets cb join cb.status s where s.code = ?1 " + "group by c2.id) tmp where c1.id = tmp.id order by tmp.minDate")
thank you!
Solution
No, there can be no subquery in the select clause of a jpql query
Jpql supports subqueries in where and having clauses It can be part of (at least) any, some, all, in, exist expressions. Of course, it can use ordinary conditional expressions:
SELECT a FROM A a WHERE a.val = (SELECT b.someval FROM B b WHERE b.someotherval=3)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码