Код: Выделить всё
public class FooBar{
@Id
private long id;
private Long fooNumber;
private Long barNumber;
...
//Other inconsequential properties
}
Код: Выделить всё
SELECT * FROM foo_bar WHERE (foo_number, bar_number) IN ((1,2),(1,4),(99,45))
Код: Выделить всё
SELECT * FROM foo_bar WHERE (fooNumber, barNumber) IN :List(FooBarTuple)
Код: Выделить всё
@Repository
public interface FooBarRepository extends CrudRepository {
@Query("SELECT id, foo_number, bar_number FROM foo_bar WHERE (foo_number, bar_number) IN :fooBarList;")
List findFooBarIn(@Param("fooBarList") List fooBarList);
}
public class FooBarTuple {
private Long fooNumber;
private Long barNumber;
}
@Service
public class FooBarService {
//Repository inject, other methods
public List getFooBar(List fooBarTupleList) {
return fooBarRepository.findFooBarIn(fooBarTupleList);
}
}
Код: Выделить всё
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Код: Выделить всё
Executing prepared SQL statement [SELECT id, foo_number, bar_number FROM foo_bar WHERE (foo_number, bar_number) IN ?, ?, ?;]
PS: Обратите внимание, что это для Spring Data JDBC а не JPA.
Подробнее здесь: https://stackoverflow.com/questions/767 ... in-columns
Мобильная версия