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
@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.
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: Fri Dec 15 00:39:38 GMT 2017

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

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