是否可以在 jpql 中实现类似下面的 mySQL 的功能?
select * from PERSON p where (p.name, p.country)
IN (('Bryan', 'Netherlands'), ('Candice', 'New Zealand'), ...);
其中“...”是列表的延续。我想创建一个新实体列表作为值的占位符,但我不确定如何使其工作。我正在考虑以下内容:
@Query(
value = "select p from Person p where (p.name, p.country) in :personList")
List<Person> findPersonsIn(@Param("personList") List<Person> personList);
我知道这是非常错误的,但我希望有人能够阐明如何在 JPA 或 JDBC 中实现上述 MySQL 语句。
最佳答案
是的。使用 AND 运算符:
select * from PERSON p where ( p.name IN ('Bryan', 'Netherlands') ) AND ( p.country
IN ('Candice', 'New Zealand') ), ...);
关于java - JPA 选择多个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61205029/