0

i add two field to my domain Class ContentSequence : lastUpdated,dateCreated ,which is updated automatically by GORM.

After running the application again , i try to get a record :

ContentSequence.get(1);

Unfortunately, i get the following in console of Web interface : org.springframework.dao.TransientDataAccessResourceException: Hibernate operation: could 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

and in terminal , i get :

util.JDBCExceptionReporter Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp 
4

2 回答 2

3

Error -> Cannot convert value ’0000-00-00 00:00:00′ from column XX to TIMESTAMP Reason > 0000-00-00 00:00:00 is outside the range of a TIMESTAMP value (in fact, it won't work with a DATE field either). Solution -> modify JDBC option jdbc:mysql://localhost/test?zeroDateTimeBehavior=convertToNull

于 2013-09-04T01:15:13.100 回答
0

I do manually a queries SQL to update the value of Date field since Timestamp has minimum

UPDATE content_sequence
SET date_created = '2013-08-08 00:00:00';
    UPDATE content_sequence
SET last_updated = '2013-08-08 00:00:00';

and now, it is work.

于 2013-08-14T15:11:52.220 回答