tags:

views:

632

answers:

1

I have a TIMESTAMP column on a table that is set to null when a record is initially inserted. I would like to update the value to the current time. My generated entity has a set method for the field as such:

setCloseDate(Timestamp closeDate)

However I do not want to generate/specify the timestamp from java code. Is there any way to annotate the attribute to indicate to use the current time at the database level when persisting the entity?

If not, what would be a good strategy for performing an update like this?

Under the covers the query I want to run is like this:

update CASE_FILE set CLOSE_DATE=CURRENT_TIMESTAMP where ID=1

I'm just getting started with JPA...so could be missing something fairly obvious here. Thanks!