If I pass an empty list into a JPA query, I get an error. For example:
List municipalities = myDao.findAll(); // returns empty list
em.c
Assuming the SQL query to be like
(COALESCE(:placeHolderName,NULL) IS NULL OR Column_Name in (:placeHolderName))
Now, If the List is of type String then you can pass as
query.setParameterList("placeHolderName",
!CollectionUtils.isEmpty(list)? list : new ArrayList(Arrays.asList("")).
And If the List is containing the Integer values then the syntax is like below:
If(!CollectionUtils.isEmpty(list)){
query.setParameterList("placeHolderName",list)
}else{
query.setParameter("placeHolderName",null, Hibernate.INTEGER)
}