I have the following code (simplified for clarity/brevity):
@Entity
@Table(name="mytable", schema="schemaName")
public class MobileDeviceData {
@Id
@Column(name="id")
private String id;
@Column(name="activitydetecteddate")
private ZonedDateTime activityDetectedDate;
}
And CrudRepository Interface that is implemented by Springboot:
@Transactional
public interface MobileDeviceDataDao extends CrudRepository<MobileDeviceData, String> {
}
With a column field of Timestamp in the table for activitydetecteddate.
When I try to save this to the database with the call
mobileDeviceDataDao.save(mobileDeviceDataList);
I get the following error:
2015-11-06 11:57:53.095 WARN 3198 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 1292, SQLState: 22001
2015-11-06 11:57:53.095 ERROR 3198 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Data truncation: Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x15\x06\x00\x00\x07\xDF\x0B\x06\x10 \x05;?<\x80\x0' for column 'activityDetectedDate' at row 1
2015-11-06 11:57:53.096 INFO 3198 --- [nio-8080-exec-1] o.h.e.j.b.internal.AbstractBatchImpl : HHH000010: On release of batch it still contained JDBC statements
2015-11-06 11:57:53.097 WARN 3198 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning Code: 1292, SQLState: 22007
2015-11-06 11:57:53.097 WARN 3198 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x15\x06\x00\x00\x07\xDF\x0B\x06\x10 \x05;?<\x80\x0' for column 'activityDetectedDate' at row 1
2015-11-06 11:57:53.108 ERROR 3198 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement] with root cause
com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x15\x06\x00\x00\x07\xDF\x0B\x06\x10 \x05;?<\x80\x0' for column 'activityDetectedDate' at row 1
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3868)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3806)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2470)
Can someone please tell me what I am doing wrong and how I can get the code correctly converted from ZonedDateTime to Timestamp.