datetime - JPA, Glassfish, Mysql: UTC time conversion occuring twice -


I am getting mad ... I have recently seen that time is wrong in my JPA-managed organizations I have a date area:

  • reaching my personal timezone CET, even for a machine running a glassfish and a MySQL.
  • Glassfish is instructed to use the default time zone as UTC: a @ startup -bine set
  • Caching is disabled in persistence.xml

    Here's what:

    • In the unit A, the field SyncTimestamp of java.util is date .
    • When a particular resource is triggered, the timestamp is now set: a.setSyncTimestamp (new date ()) . Let's take my watch on the wall 14: 30: 00 hours (the date left for brevity).
    • The institution is managed, so the update ends in DB. The expected value of the database in the database (type DATETIME ) is "12: 30: 00 H" - CET is currently 2h ahead of UTC.
    • Shows the transaction timestamp as "12: 30: 00.123 Z" (notes milliseconds).
    • After retrieving the unit from the database again, accessing the recipient (disabled caching) in a different transaction, output "10: 30: 00Z"

      So when the unit is loaded from the DB, it seems that JPA is a timetamp of UTC CET, which is useless for 2 hours, it changes again.

      I have read a lot of posts about JPA and timezone, etc. What I have learned: neither do I understand the timezone on java.util.Date nor MySQL DATETIME . This should not be a problem, unless everything is always considered "UTC", right? Now Why can change the value of JPA (I think?)?

      (PS: I've got a post. It suggests to put JVVM in UTC at the time of time - but no, what does my startup bean do?)

      Edit : An important information was detected which had disappeared. To prepare for glassfish clustering, I had transferred the database to my MySQL db for EJB timer service. Consequently, the JDBC driver was extracted from the application in the glassfish Lib-directory.

      OK, I came to know what's going on, and how to fix it.

      It seems that due to the start of EJB timer service first my @ startup -bien, mysql JDBC driver is loading and timezone Starting with (which is the system default = CEST at that time)

      Setting default timezone to UTC does not affect the JDBC driver later (is it possibly a glassfish bug?).

      The solution is to define the default timezone of UTC's GMM:

        asadmin create-jvm-options -Duser.timezone = UTC asadmin restart- domain    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -