-->
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.  [ 3 posts ] 
Author Message
 Post subject: how to create date on save or update?
PostPosted: Wed Jan 16, 2008 2:50 am 
Newbie

Joined: Wed Dec 12, 2007 3:04 pm
Posts: 9
Hi,

I want to know how to populate the date field, I have something like this of every entity

date_created
date_updated

I am using annotations, hibernate 3.2 and calling saveOrUpdate.
So the problem is first time date_created should be updated,
next time on every update, date_updated
but i am calling single method saveOrUpdate.
How to achieve this is there is any annotations to do this?

Pen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 7:52 pm 
Newbie

Joined: Wed Dec 12, 2007 3:04 pm
Posts: 9
still waiting for reply

thanks
Pen


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 16, 2008 10:42 pm 
Newbie

Joined: Wed Dec 12, 2007 3:04 pm
Posts: 9
Hi,
I am trying to add the default database date,
I get the date_created updated with the date,
but date_updated as null,

If i switch the annotation I get other way,

when I add this to both, I get null for the both
what is the solution?


@Column(name="date_created")
public Date getDateCreated() {
return dateCreated;
}

@Column(name= "date_updated",updatable = false, insertable = false)
@org.hibernate.annotations.Generated(
org.hibernate.annotations.GenerationTime.ALWAYS)
public Date getDateUpdated() {
return dateUpdated;
}


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

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.