-->
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.  [ 5 posts ] 
Author Message
 Post subject: update timestamp
PostPosted: Sat Jan 20, 2007 10:12 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:18 am
Posts: 28
I've got a timestamp property that simply needs to be automatically updated on every insert or update. I guess what I need is this:
http://opensource.atlassian.com/project ... se/ANN-441

If I don't use any detached instances anywhere, is it safe to use @Version instead? I don't want any actual version checking from Hibernate, I want the "last-commit-wins strategy".


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 21, 2007 9:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
a user type can do the trick, @Version is not what you want

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 22, 2007 12:39 am 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:18 am
Posts: 28
Do you mean something like this?

Code:
   public void nullSafeSet(PreparedStatement st, Object value, int index)
      throws HibernateException, SQLException
   {
      Date now = new Date();
      Hibernate.TIMESTAMP.nullSafeSet(st, now, index);
   }



But how can I make the db generate the timestamp instead?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 3:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
ah, then you need ANN-411, if you're interested in providing a patch (it should not be too complex), let me know.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 24, 2007 3:50 pm 
Beginner
Beginner

Joined: Wed Jan 25, 2006 10:18 am
Posts: 28
Ok, thanks.
I don't yet feel comfortable enough with Hibernate to dig into the source and provide a patch. For now, I'll just wait until someone else needs it more than I do and fixes it. ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.