简体   繁体   中英

How to create a request for a complex query? @Query jpql spring jpa

How to create a request for a complex query in JpaRepository with the use of @Query ? I am concerned about the relationships between entities. They may affect the preparation of the request.

Needed query SQL, my version @Query:

Ok so more advisable way of declaring your query would be :

@Query( "SELECT bu.email " +
               "FROM Businesscentr bu
                       INNER JOIN bu.bannersSet bs
                       INNER JOIN bs.clicks c " +
               "WHERE c.fullNameClient = :fullNameClient" // optional 
      )

You only use the old join style when you have to join by non-primarykey values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM