Select with in clause from list with JPA

1 · Adrian Matei · Sept. 17, 2021, 10:08 a.m.
The native SQL query we want to map in JPA is similar to the following: SELECT * FROM PARTNER where PARTNER_NUMBER IN ('id1', 'idn'). With JPA you can use a TypedQuery for example and set the expected list of the IN clause directly as query parameter @Stateless public class PartnerDataRepository { @Inject private EntityManager em; public List<PartnerData> findPartnerDataFromList( List<String> partnerNumbers) { TypedQuery<PartnerData> query = em.createNamedQuery( PartnerData.FI...