mybatis Error: All elements are null [How to Solve]

The result of mybatis query is actually List list = {null}
will enter the loop traversal code, in the loop inside T = null will be a null pointer exception

Solution:

1. Remove the empty object element from list: list.removeAll(Collections.singleton(null));
2. Add ifnull (.... ,0).to the select field in the SQL statement.

Read More: