Hibernate: SQLException: Cannot convert value ‘0000-00-00′ from column to TIMESTAMP.
Recently when fetching row using Hibernate I got following Exception:
Caused by: java.sql.SQLException: Cannot convert value ‘0000-00-00′ from column 5 to TIMESTAMP.
This I got when calling findByExample method on Hibernate’s EntityManager.
The cause for this was a 0 value in the updated_date column of the table at db. The update_date column is of type DATE. Recently I had imported some data to this table and all the columns had ‘0000-00-00’ as updated_date. Clearly MYSQL was failing to convert the date value to timestamp.
Solution for this was to append zeroDateTimeBehavior=convertToNull in the connection URL.
db.url=jdbc:mysql://localhost:3306/mydb?autoReconnect=true&zeroDateTimeBehavior=convertToNull
This is to enable the driver to handle the DATETIME values that consist of zeroes. This solved my problem.









And you solved my day
Thank you