網頁

2012年8月31日 星期五

JPQL in clause with empty list

jpql:
select e from employee e where e.id in :param

:param 是個list

如果list裡面沒有值(.isEmpty() == true),就會出現以下莫名其妙的錯誤
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 1 

eclipselink轉譯出的sql:
WHERE (t1.IN ())

就是因為in裡面沒有東西,所以sql出錯。eclipselink居然沒有處理這種錯誤,還丟出這麼撲朔迷離的Exception......


沒有留言:

張貼留言