-->
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: update datetime and timestamp column
PostPosted: Fri Apr 18, 2008 11:51 am 
Newbie

Joined: Wed Oct 17, 2007 4:36 pm
Posts: 2
Basically, I am trying to map a table like below,

created_on datetime not null default current_timestamp,
modified_on timestamp not null default current_timestamp,

Here is my code,
@Column(name="modified_on", updatable=false, insertable=false, columnDefinition="timestamp not null default current_timestamp")
@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.ALWAYS)
private Date modifiedOn;

@Column(name="created_on", updatable=false, insertable=false, columnDefinition="datetime not null default current_timestamp")
@org.hibernate.annotations.Generated(org.hibernate.annotations.GenerationTime.INSERT)
private Date createdOn;

I want these two column would be updated automatically,
during insert, created_on would have current_timestamp
during every update, created_on would left unmodifed by modified_on will be updated.

I am new to hibernate, how can I accomplish this.

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.