0 Replies Latest reply on Oct 5, 2005 4:15 AM by jc7442

    Problem using @PreUpdate  in a callback

    jc7442

      I have the following model:
      Widget->1AuditInfo

      @EntityListener(AuditCallbackListener.class)
      public class Widget implements Serializable,Auditable {
      ...
       @Embedded
       public AuditInfo getAuditInfo() {
       return auditInfo;
       }
      ...


      The AuditCallbackListener looks like:
      public class AuditCallbackListener {
       @PreUpdate
       public void doPreUpdate(Auditable audit) throws Exception{
       System.out.println("doPreUpdate ...");
       AuditInfo info = audit.getAuditInfo();
       info.setLastUpdated(new Date(System.currentTimeMillis()));
       }
       }


      When I update a widget, I any case I see the trace write in @PreUpdate.

      When AuditInfo is declared as embedded, the last update date is persisted in the DB.

      But if AuditInfo is an entity (@OneToOne relationship instead of @embedded) the date is not persisted in DB.

      Is it a bug ? Any suggestions are welcome !

      Regards