Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » @Version timestamp; select local or server time(Timestamp returned by the EclipseLink for the locking field is the local time while the server time is required.)
@Version timestamp; select local or server time [message #1775592] Wed, 01 November 2017 21:25
Amita Mehta is currently offline Amita MehtaFriend
Messages: 23
Registered: May 2013
Junior Member
We are using the @Version with timestamp
@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 -
protected void prePersistAuditFields() {
final Date date = new Date();
this.setCreateTime(new Timestamp(date.getTime()));
final String user = RequestContext.getLocalInstance().getUserId();

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

test (
VALUES (?, ?, ?, ?, ?)

[10/31/17 16:14:44:893 UTC] 0000001c SystemOut O [EL Fine]: sql: Connection(972996009)--
bind => [
2017-10-31 16:14:44.889,
2017-10-31 12:14:45.033,

Thanks for the help.
Previous Topic:Dynamic explore xsd attributes or metadata information through Moxy question
Next Topic:Logging about time to create entity manager factory Impl should exist
Goto Forum:

Current Time: Tue Mar 20 13:26:51 GMT 2018

Powered by FUDForum. Page generated in 0.01853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software