4 Replies Latest reply on Jun 13, 2012 11:23 AM by adamw

    ENVERS stores different date than Hibernate - different timezone - is there a fix/workaound ?

    dkelly

      Using below. Hibernate stores a UTC date. Envers appears to ignore the @Type annotation. Any help appreciated.

       

       

       

        /**

           * @return The date (and time component for a start date) according to the

           *          delivery system

           */

          @Type(type = "utcTimestamp")

          @Column(columnDefinition = "DATE", nullable = false)

          @Temporal(TemporalType.TIMESTAMP)

          public Date getDateAndTime() {

              return dateAndTime;

          }

       

          /**

           * @param date The date (and time component, for a start date) according to

           *          the delivery system

           */

          public void setDateAndTime(final Date date) {

              dateAndTime = date;

          }

        • 1. Re: ENVERS stores different date than Hibernate - different timezone - is there a fix/workaound ?
          dkelly

          Sorry guys, I should have mentioned we are using hibernate 3.5.6 and the ENVERS that ships with it. The date auditing is very important for this App and I have championed ENVERS to be our audtiing solution. So I would really appreciate help on this.

           

          Regards

           

          D......

          • 2. Re: ENVERS stores different date than Hibernate - different timezone - is there a fix/workaound ?
            adamw

            And what is Envers storing? Did you try the newest version?

             

            Adam

            • 3. Re: ENVERS stores different date than Hibernate - different timezone - is there a fix/workaound ?
              dkelly

              The product is using Hibernate 3.5.6 and this wont get upgraded. Is it possible (excuse if this is a stupid question) a later version of ENVERS than what is shipped with 3.6.5. Can the newer version just be referenced in the POM file. As for the question. When the annotation is used Hibernate stores date as UTC, while ENVERS stores the date in local time. So they are 5 hours out of whack.

               

              Also in case anyone has seen this (i dont want to swamp the above issue), we are also seeing an error where audit records are being written even when the transacation failed on the main table with a

              error below. Cant see any help on web any pointers would be great.

               

              D....

               

              Caused by: javax.persistence.RollbackException: Error while committing the transaction

              at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93) ~[hibernate-entitymanager-3.5.6-Final.jar:3.5.6-Final]

              at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:467) ~[org.springframework.orm-3.0.5.RELEASE.jar:3.0.5.RELEASE]

              ... 107 common frames omitted

              Caused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 0

              at java.util.ArrayList.RangeCheck(ArrayList.java:547) ~[na:1.6.0_31]

              at java.util.ArrayList.get(ArrayList.java:322) ~[na:1.6.0_31]

              at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259) ~[hibernate-core-3.5.6-Final.jar:3.5.6-Final]

              at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:179) ~[hibernate-core-3.5.6-Final.jar:3.5.6-Final]

              at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321) ~[hibernate-core-3.5.6-Final.jar:3.5.6-Final]

              at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51) ~[hibernate-core-3.5.6-Final.jar:3.5.6-Final]

              at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206) ~[hibernate-core-3.5.6-Final.jar:3.5.6-Final]

              • 4. Re: ENVERS stores different date than Hibernate - different timezone - is there a fix/workaound ?
                adamw

                Well, it would be best if you wrote a test demonstrating the problem and try it in Envers 3.5.6 and 4.1. Then it would be possible to debug quite easily as well.

                 

                As for the transaction failures ... that shouldn't happen of course. There were some fixes around that in the 3.5 branch, but 3.5.6 should have them all I suppose. Again, hard to say without sitting with the debugger or trying a newer version.

                 

                Adam