@Version timestamp; select local or server time [message #1775592] |
Wed, 01 November 2017 21:25 |
ELUser Mising name Messages: 26 Registered: May 2013 |
Junior Member |
|
|
We are using the @Version with timestamp
@Version
@Column(insertable = true, updatable = true, unique = false, name = "UPDATE_TIME",
nullable = false,
columnDefinition = "timestamp")
private Timestamp updateTime;
We set the createTime in the prePersist method -
@PrePersist
protected void prePersistAuditFields() {
final Date date = new Date();
this.setCreateTime(new Timestamp(date.getTime()));
final String user = RequestContext.getLocalInstance().getUserId();
this.setCreateUser(user);
this.setUpdateUser(user);
}
What we are noticing is that the createTime is populated with the GMT, but the updateTime that EclispeLink populates is the using the local time.
How can I tell EclipseLink to use the server time and not the local time?
I tried adding this to the persistence.xml but it does not work (still get the local time)
<property name="eclipselink.locking.timestamp.local" value="false" />
From the log we see this SQL being generated by EclipseLink
INSERT INTO
test (
id,
createTime,
createUser,
updateTime,
updateUser
)
VALUES (?, ?, ?, ?, ?)
[10/31/17 16:14:44:893 UTC] 0000001c SystemOut O [EL Fine]: sql: Connection(972996009)--
bind => [
B80C446F-255C-4687-8B37-8496789A4970,
2017-10-31 16:14:44.889,
tester,
2017-10-31 12:14:45.033,
tester
]
Thanks for the help.
|
|
|
Powered by
FUDForum. Page generated in 0.03111 seconds