1 Reply Latest reply on Sep 19, 2008 10:24 AM by Tim Shaw

    Temporals and ON UPDATE CURRENT_TIMESTAMP

    Dennis Dietrichs Newbie

      Hello there,

      I have an entity bean with a field "dtupdated" that I would like to have
      set to the current timestamp on each update of the dataset. It is annotated
      the following way.

      @Temporal(TemporalType.TIMESTAMP)
      @Column(columnDefinition="TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
      private Date dtupdated;

      My DB is mySQL.

      If I retrieve this entity bean from the DB now, make changes and write it back to the database, the dtupdated field will of course not be set to CURRENT_TIMESTAMP, because it's previous value will be explicitly passed in the UPDATE statement on the DB and CURRENT_TIMESTAMP is only set, if a NULL value is passed...

      How can I create a field with the desired behaviour? Any good solutions out there?

      Thanks a lot for your help -

      Dennis