I have a native Query that return a list of objects, i need to pass an array as parameter to the function getAllUsers.
@Repository
public interface UserRepository extends JpaRepository<User, Integer> {
@Query(nativeQuery = true, value = "SELECT id FROM users WHERE code1=(?1)[0] AND code2=(?1)[1]")
public List<Object[]> getAllUsers(List<String> list);
}
The problem was that i can't get values of the parameter list in the query : code1=(?1)[0] AND code2=(?1)[1].
I tried to use Types :
public List<Object[]> getAllUsers(String[] list);
public List<Object[]> getAllUsers(String ...list);
But always without result
Many thanks For any help
code1&code2are different columns inuserstable? if yes, then syntax is wrong & you might need to use 2 arguments in your method.code1andcode2as example, in fact i have 24 :code1, code2, code3, ... code24, this is why it's not practical to use parameters ... also i can add codes (code25, 26, ...)whereclause of your query.