persistence icon indicating copy to clipboard operation
persistence copied to clipboard

@CurrentTimestamp

Open lukasj opened this issue 12 years ago • 8 comments

New annotation "@CurrentTimestamp" should inject the current timestamp of a transaction into a data field.

The annotation will guarantee that at the transaction start the timestamp is produced once, so all uses of the annotation within the same transaction will guarantee to inject the same timestamp value.

This is another essential business need, as sometimes transactions run rather long, but all written data shall have synchronized timestamps.

lukasj avatar Feb 23 '13 07:02 lukasj

  • Issue Imported From: https://github.com/javaee/jpa-spec/issues/49
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @ldemichiel

lukasj avatar Aug 31 '18 16:08 lukasj

@glassfishrobot Commented Reported by mkarg

lukasj avatar Feb 23 '13 07:02 lukasj

@glassfishrobot Commented rbygrave said: Personally I'd argue for 2 annotations like @WhenCreated and @WhenUpdate. I've already mentioned this in #48 wrt SQL2011 History support and auditing etc. Just adding this comment here in case ... something happens !!

lukasj avatar Nov 24 '16 08:11 lukasj

@glassfishrobot Commented neilstockton said: +1 for @CreateTimestamp and @UpdateTimestamp, and with both taking the timestamp at FLUSH. The reason to use flush timestamp is that with updates you may have multiple updates of an object in a transaction, so need to distinguish which update.

lukasj avatar Nov 25 '16 18:11 lukasj

@glassfishrobot Commented Parent-Task: JPA_SPEC-36

lukasj avatar Feb 23 '13 07:02 lukasj

@glassfishrobot Commented This issue was imported from java.net JIRA JPA_SPEC-49

lukasj avatar May 05 '17 06:05 lukasj

@andyjefferson Commented FWIW, DataNucleus implements this as 2 new annotations @CreateTimestamp and @UpdateTimestamp.

lukasj avatar Jul 04 '17 17:07 lukasj

These annotations should be applicable for fields of type java.sql.Timestamp, or java.time.Instant.

andyjefferson avatar Jul 06 '20 17:07 andyjefferson