attempted to return null from a method with a primitive return type (int).

created at 12-14-2021 views: 26

cause of the error

The reason for this error is that the sql statement did not query the data, and the return was `null`. And the dao layer method we defined returns as int, and the following prompt will appear:

return null from a method with a primitive return type (int). (Trying to return null from a method with a primitive return type (int))

Ingeter is a wrapper class of int, the initial value of int is 0, and the initial value of Ingeter is null.

solution

Change the return type of the dao layer to Integer.

created at:12-14-2021
edited at: 12-14-2021: