How to create a request for a complex query? @Quer

2019-04-14 09:51发布

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:

1条回答
Viruses.
2楼-- · 2019-04-14 10:05

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.

查看更多
登录 后发表回答