JPA查询选择“IN”子句中的多个值
我想为以下SQL语句创建JPA参数化查询
select * from car where (colour, speed) in (('red', 50), ('blue', 70))
此查询返回预期结果
entityManager.createQuery("from Car c where (c.colour, c.speed) in (('red', 50), ('blue', 70))", Car.class).getResultList();
如何将当前硬编码的值作为参数传递?
我提出了以下“工作”解决方案。 但我担心无法保证所有参数对都按预期顺序传递? 我不想让速度为“50”的“蓝色”汽车。
编辑:删除因为它不能按预期工作,另请参阅@Gas评论