map为空时调用keySet()传给jpa导致的bug

kyaa111 2年前 ⋅ 551 阅读
userService.deleteNotInId(userMap.keySet());
@Modifying
@Query(value = "DELETE FROM user WHERE id NOT IN (:iqs)", nativeQuery = true)
void deleteNotInId(@Param("ids") Iterable<String> iqs);

当userMap size为0时

预期jpa sql为DELETE FROM user WHERE iq NOT IN ('')

而实际sql为 DELETE FROM user WHERE iq NOT IN (null)