I've seen this question asked a few times but haven't seen an answer. I would like to update certain timestamp columns with the database server's current date/time. For Oracle and MySQL you would use sysdate. But I don't see a way to do this using Hibernate. If I do a myobject.setLastDate(currenttime) I must send a Java timestamp value. I need a way to tell Hibernate to add "sysdate" to the SQL rather than a hard-coded timestamp value.
I could setup a trigger in the database and set the Hibernate mapping so update="false" and insert="false", but it seems there should be a way to handle this in Hibernate. And it is bad practice to use the application server's current time since you may have multiple application server's accessing the same database, and their clocks may be slightly different.
Thanks.
|