119 words

auto generate timestamp

#1
2011-08-11 05:23

Hi all,

How can I create auto timestamping column?

I want the database to generate the timestamp.

I tried google but suggested solutions doesn't work in objectDB.

http://stackoverflow.com/questions/811845/setting-a-jpa-timestamp-column-to-be-generated-by-the-database

- Pawel

 

pawel
pawel's picture
Joined on 2011-08-11
User Post #1
#2
2011-08-11 06:55

Yes, currently ObjectDB supports only numeric values in version fields.

However, you can hold the timestamp in an ordinary Date / Timestamp field and update it in an event callback method (@PrePersist, @PreUpdate).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #515
#3
2011-08-11 07:45

Not always...
If your server runs on separate computer and clients clocks are not synchronized or what worse are from different time zone’s you can have a troubles...

pawel
pawel's picture
Joined on 2011-08-11
User Post #2
#4
2011-08-11 07:55

You are right - a version field is preferred. It will be supported in future versions.

You can, however, use the server time in the event callback by running a query (not very efficient but should work).

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #516

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel