I need to create a JPA native query relevant to the example below:
select * from inventory where (server, product) in (('server1','product1'), ('server2','product2'), ('server1','product3'));
I have created a native query:
@Query(
value = "select server, product from inventory where (server, product) in (:myList)",
nativeQuery = true
)
List<Product> getProducts(List<List<String>> myList);
But when I pass List of Lists as an argument:
List<List<String>> myList= Arrays.asList(
Arrays.asList("server1","product1"),
Arrays.asList("server2","product2"),
Arrays.asList("server1","product3")
);
List<Product> products = myRepository.getProducts(myList);
I get an error
java.sql.SQLSyntaxErrorException: ORA-00920: invalid relational operator
I use Oracle database. Please tell me, what am I doing wrong?
This question is not about passing a flat List into a native query to filter db results by 1 column (this works fine) but how to pass a list of nested lists into a query to filter db results by 2 columns.