Michael
Michael

Reputation: 21

Versionning with LocalDateTime causing OptimistickLockException

Currently upgrading our java/jsf/primefaces application, I'm facing folowing issue:

I changed the versioning date from Date datatype to LocalDateTime, since that i'm having a OptimistickLockException when saving an Entity for the second time, on my local machine. (Windows64 + Wildfly23 + OpenJDK 12 + oracle-ojdbc6 driver) I've already debugged showed the current values of the jpaVersion on screen everything is fine before the update.

On the dev server (Linux + Wildfly23 + OpenJDK 12 + oracle-ojdbc6 driver), it's working fine. Both share the same DB.

Someone have an idea what could be the cause ? Would appreciate you're help.

Best regards

Upvotes: 0

Views: 131

Answers (1)

Michael
Michael

Reputation: 21

I figured it out: It has something to do with the precision of the clock where the application is running.

On the Windows I've a precision of nanoseconds(9) on the Linux deployments it has a precision of milliseconds(6), therefore in order use LocalDateTime on Multi-platforms (Windows/Linux) the time must be truncated/converted to milliseconds in order to avoid Locks. Or simply continue using Date for versioning, always has a precision of (6/Milliseconds).

Upvotes: 1

Related Questions