我在我的域类ContentSequence中添加两个字段:lastUpdated,dateCreated,由GORM自动更新。
再次运行应用程序后,我尝试获取记录:
ContentSequence.get(1);
不幸的是,我在Web界面的控制台中获得以下内容:
org.springframework.dao.TransientDataAccessResourceException:Hibernate操作:可以not load an entity: [com.abdennour.content.ContentSequence#200]; SQL [select contentseq0_.id as id17_0_, contentseq0_.version as version17_0_, contentseq0_.chapter_id as chapter3_17_0_, contentseq0_.date_created as date4_17_0_, contentseq0_.difficulty as difficulty17_0_, contentseq0_.last_updated as last6_17_0_, contentseq0_.level_id as level7_17_0_, contentseq0_.name as name17_0_, contentseq0_.other as other17_0_, contentseq0_.owner_id as owner10_17_0_, contentseq0_.subject_id as subject11_17_0_, contentseq0_.type as type17_0_ from content_sequence contentseq0_ where contentseq0_.id=?]; Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp; nested exception is java.sql.SQLException: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
在终端,我得到:
util.JDBCExceptionReporter Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp
答案 0 :(得分:3)
错误 - >无法将值'0000-00-0000:00:00'从第XX列转换为TIMESTAMP 原因> 0000-00-00 00:00:00超出TIMESTAMP值的范围(事实上,它也不适用于DATE字段)。 解决方案 - >修改JDBC选项 JDBC:MySQL的://本地主机/测试zeroDateTimeBehavior = convertToNull
答案 1 :(得分:0)
我手动查询SQL以更新Date字段的值,因为Timestamp具有最小值
UPDATE content_sequence
SET date_created = '2013-08-08 00:00:00';
UPDATE content_sequence
SET last_updated = '2013-08-08 00:00:00';
现在,这是工作。