spring-boot - 在spring data jpa中使用两个不同的实体加入
问题描述
我有 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
推荐阅读
- mysql - Mysql 5.7 复制(A -> B -> C)不工作
- python - pdfWriter.write 加密后挂起
- java - 如何使输入函数 jdatechooiser netbens
- android - Fragment 可以像 MainActivity 一样工作吗?
- javascript - 如何在搜索栏中获取项目的详细信息?
- c++ - 在 CMake 中设置各种编译器以创建共享库
- r - 改变列表中的日期值并获取范围
- postman - 错误:在邮递员中连接 ECONNREFUSED 127.0.0.1:8081
- python - Python从服务器上的txt读取行范围并将它们写入本地文件
- c++ - 如何通过 Qt c++ gui 应用程序访问 USB 摄像头