Reputation: 421
I am loading a value from the database, which is a Timestamp datatype in IBM DB2, but needs to be mapped as java.util.Date for the JSF GUI. I thought just tell JPA it is a timestamp and it will manage it. I did it this way:
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "DATE")
private Date myTimeStampAsDate;
However if there is the Date 9999-12-31 23:59:59 in the database it will be round up in my Entity to the date 10000-01-01 00:00
If I map it as a real java.sql.Timestamp it loads even the milliseconds perfectly. What do I need to do to avoid this "rounding behavior" but keep java.util.Date for my entity and the GUI?
Upvotes: 1
Views: 2421
Reputation: 421
Openjpa will provide a data dictionary option to not round the milliseconds for java.util.Date
properties annotated with @Temporal(TemporalType.TIMESTAMP)
. Hopefully it will come with version 2.2.1/2.3.X and ongoing. Please follow this Jira Issue to see when it will be entirely solved:
https://issues.apache.org/jira/browse/OPENJPA-2159
The property seems to look like this in your persistence.xml
(The default will be true
):
<property name="openjpa.jdbc.DBDictionary" value="roundTimeToMillisec=false" />
The default will be true
Upvotes: 1