Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Auto-fill date field

I would use a trigger. Below is an example of Oracle trigger that assigns id using a sequence.
 
CREATE OR REPLACE TRIGGER "TEST"."RETURNING_TRIGGER_INS" BEFORE
INSERT ON "TEST"."RETURNING" FOR EACH ROW BEGIN
  SELECT RETURNING_ID_SEQ.NEXTVAL INTO :new.ID FROM DUAL;
END;
----- Original Message -----
Sent: Sunday, March 14, 2010 8:29 AM
Subject: [eclipselink-users] Auto-fill date field

Hello all,
I have an event record, which has a timestamp field:
 
...
    @Temporal(TemporalType.TIMESTAMP)
    public Calendar getEventTime() {
        return eventTime;
    }
...

I would like to have the DB itself fill in the field when the entity is first persisted. This is important as I have a few servers talking to the same DB, and filling the timestamp in the java tier exposes the application to problems caused by  differences between servers' clocks (e.g. in the history table, email is received before it is sent).

Any ideas?
Thanks in advance,
Michael Bar-Sinai

p.s. Obviously, we have the systems team work on their NTP-clock-syncing stuff, but an application-level solution is always better :-)


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

Back to the top