This content originally appeared on DEV Community and was authored by goffity
Problem when wanting to mapping values from MySQL query to Object in JAVA but MySQL Query returns NULL
If Application is written in spring boot with JDBCTemplate and mapping to Object, the exception will occur.
org.springframework.beans.TypeMismatchException
can be solved by use IFNULL
SELECT IFNULL(emp_id,0) FROM emp WHERE 1=0;
Output
0
Reference:
https://dev.mysql.com/doc/refman/5.7/en/flow-control-functions.html
https://www.w3schools.com/sql/func_mysql_ifnull.asp
This content originally appeared on DEV Community and was authored by goffity

goffity | Sciencx (2021-07-05T16:41:35+00:00) MySQL query default value is query is NULL. Retrieved from https://www.scien.cx/2021/07/05/mysql-query-default-value-is-query-is-null/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.