首页 > 解决方案 > 使用 IN 对象列表将 Oracle SQL 查询转换为 Spring JPA

问题描述

我无法将以下工作 SQL 查询转换为 JPA:

SELECT a.* FROM TableA a1, TableB b1, TableC c1 WHERE
a1.c  = c1.c AND a1.b = b1.b AND 
(a1.attr1, b1.anotherAttrB, c1.anotherAttrC) IN (('2016','2004','678'), ('2020','2004','678'));

这是我尝试过的 JPA 查询,但失败了:

@Query(value = "SELECT a FROM TableA a1, TableB b1, TableC c1 WHERE
 a1.c  = c1.c AND a1.b = b1.b AND
(a1.anotherAttrA, b1.anotherAttrB, c1.anotherAttrC) IN :myObjectList")
public List<A> findByMyObjectListIn(@Param("myObjectList") List<MyObject>myObjectList);

其中 MyObject 只是一个带有三个字符串的简单 POJO。

有什么想法吗?

标签: javasqlspringjpa

解决方案


推荐阅读