I use Hibernate
and JpaRepository
to handle my DB operations.
I have this query (to simplify because original query is quite big):
@Query(value="select * from history h where h.project_id in :projects", nativeQuery=true)
List<History> getHistoriesByProjectsIn(@Param("projects")List<Long> projects);
and it is working when I pass valid and not empty List<Long>
. However when I pass empty list which may happen and it is not unusual in my scenario I get:
org.postgresql.util.PSQLException: ERROR: syntax error at or near ")"
Can anyone give me a hint on how to get rid of it?