I want to write a complex hql query with relationships from 3 tables. It is necessary to make a selection of the selected columns so that they are located by ID
@Query("SELECT p.regId, p.method, p.tax, p.fee, p.netAmount, r.countSec, p.status " +
"FROM P p INNER JOIN R r INNER JOIN D d on p.regId = r.id AND p.regId = d.id")
List<P> findAllByRegId(String regId);
My compiler cannot execute the request, I don’t understand what the problem is! Help, please
org.postgresql.util.PSQLException: ERROR: syntax error at or near "join"
2
Answers
The format for multiple joins is
Your join is totally wrong. You have to add
ON
keyword and map primary key and foreign key in first inner join.Here is your join, which is wrong
Here is the correct syntex for multiple join
Here down is modified query