JPA find all records by list of composite keys

Viewed 10

I have a table (postgresql) where the pk is composite (a,b,c). I want to pull a bunch of records by their ids in the fewest number of db operations.

is there a way for jpa to do something like this?

-- keys = [[1,2,3],[4,5,6],[7,8,9]...] list of composite key values to query

select * from table where a = keys[0][0] and b = keys[0][1] and c = keys[0][2]
select * from table where a = keys[1][0] and b = keys[1][1] and c= keys[1][2]
.
.
.


Is there a way for jpa to generate this sql for me? Or if I have to make the db call in a loop, a way to batch all these requests together so that there are fewer operations?

0 Answers
Related