I am using EclipseLink 2.6.0
in my project together with MySQL 5.6.19
.
Since mysql 5.6.4
supports a fieldtype DATETIME(6)
which allows to store a date with milliseconds precision in its value. Also EclipseLink 2.6.0
says it supports this functionality.
I am creating a database from my entities. And I am not able to force it to create a proper field. In logs, during database creation I constantly see:
CREATE TABLE MY_TABLE (..., DATE_FIELD DATETIME ...)
when, obviously, what I want is:
CREATE TABLE MY_TABLE (..., DATE_FIELD DATETIME(6), ...)
I tried using both, simple and annotated version:
private java.util.Date date1;
@Temporal(value = TemporalType.TIMESTAMP)
private java.util.Date date2;
but the outcome is always the same. So how does the Eclipselink supports this? How to determine the proper field type?
Thanks specializt for the tip, easy solution:
@Column(length=6)
private Date myTime;
works also with YodaTime converter (description)
@Column(length=6)
@Converter(name = "dateTimeConverter", converterClass = pl.ds.eemediation.storage.entities.converters.JodaDateTimeConverter.class)
@Convert("dateTimeConverter")
private DateTime date;