0

Is it possible combine persistence @Version + Timestamp + precision?

Expected result datetime with milliseconds 2019-07-16 14:05:40.648419.

Now I get 2019-07-16 14:05:18.000000.

@MappedSuperclass
@Getter
@Setter
public abstract class AbstractEntity<T> {

    @Version
    @Column(name = "UPDATED", nullable = false)
    private Timestamp updated;

}

@Version Timestamp is set by this functionality:

getTimestampFromServer use -> MySQLPlatform.getTimestampQuery() //default behaviour SELECT NOW();

Property use-local time in persistence.xml not help, milliseconds still .000

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Marat
  • 17
  • 1
  • 7
  • What is the field type in the database, and what precision is "SELECT NOW()" returning? Also, what "use-local time" property are you referring to? – Chris Jul 17 '19 at 15:17
  • The local time setting requires a customizer to set, see https://stackoverflow.com/questions/47997401/change-the-optimisticlockpolicy-to-use-local-time MySQL millisecond precision support requires driver versions > 5.6.4; check the MySQLPlatform initializeConnectionData class to see what version it thinks your driver is and if the type it generates is able to store it, see https://stackoverflow.com/a/9681783/496099 for details – Chris Jul 17 '19 at 15:39
  • use-local is persistence.xml . Driver mysql-connector-java-5.1.32-bin.jar not supports milliseconds. – Marat Jul 18 '19 at 08:15

0 Answers0