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

不打扰是莪最后的温柔 提交于 2019-12-06 11:42:10

问题


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:


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.



来源:https://stackoverflow.com/questions/41897719/how-to-create-a-request-for-a-complex-query-query-jpql-spring-jpa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!