-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: default sysdate, mysql, hibernate annotations
PostPosted: Mon Sep 26, 2011 1:08 pm 
Newbie

Joined: Mon Sep 26, 2011 1:01 pm
Posts: 1
Hi,

Is there any way to set a default SYSDATE on a column ?
INSERT INTO table (dateCreation, ...) VALUES (SYSDATE(),...)
I'm using hibernate 3.5.7 (with annotations) with mysql 5.1.37
My tables all have two date fields : dateUpdate and dateCreation

dateUpdate is managed by the database. Mysql allows only one column with default time, therefore dateCreation cannot have default in the DB.

We want the database date not the webserver date, so we cannot set the date in java.
We also cannot use any triggers/procedures to set the value on insert.
We want to use annotations rather than xml config if possible

The following solution would be ideal but doesn't work :
@Column(name="STATUS_DATE",columnDefinition = "Date default SYSDATE" )
public Date getStatusDate() {
return statusDate;
}

Other proposed solutions are not possible for us and not good enough anyway.
I had a look everywhere, including on JIRA and this forum and it's unclear if something is going to change and when.

Does anyone have a solution or some information ?

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.