【发布时间】:2019-04-18 13:21:09
【问题描述】:
我有 2 个不同的实体。 table1 有一列是 table2 的主键。
这两个表都尊重存储库。
如果我在其中一个存储库中编写以下查询,则会出现错误
QuerySyntaxException:意外令牌:
@Query("select new stats.UserCountDTO(b.objectiveId, count(b.objectiveId), a.locationCountry)"+
" from UserIdentityEntity a, UserObjectiveEntity b where b.userIdentityId == a.id and b.cId = ?1")
在这种情况下如何使用 spring data jpa 编写连接查询?
【问题讨论】:
-
这个
b.userIdentityId == a.id应该是b.userIdentityId = a.id -
哦,是的.. 愚蠢的错误。考虑到java约定。非常感谢它现在可以工作了。
标签: spring-boot jpa spring-data-jpa jpql