-->
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: @Version optimistic locking and timestamp
PostPosted: Fri Jun 01, 2007 12:40 pm 
Beginner
Beginner

Joined: Thu Aug 04, 2005 8:41 pm
Posts: 47
I'm trying to use @Version on a version field which is declared as timestamp in Sybase.
This timestamp is generated by database, however hibernate tries to manage its value (insert,). In hbm.xml files there are ways to specify it as generated by database with source=db generated=always.
What is the way to achieve same with annotations?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 05, 2007 4:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I don't think it's supported yet, try @Type(type="dbtimestamp")
with @Generated(ALWAYS), it might work

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 15, 2007 1:04 pm 
Newbie

Joined: Sun Jul 08, 2007 12:10 pm
Posts: 2
I can get this feature to work with this set of annotations on the version field:

Code:
@Version
@Column(insertable = false, updatable = false)
@Generated(GenerationTime.ALWAYS)
private Timestamp versionDate;


With the above annotations, I can use a Date or Timestamp type which is populated solely by the database (Oracle in this case).

However, in my domain, versionDate is really a last modified date. When new instances are created, this field is null and is only populated after an UPDATE is executed. How do I let the system know that null is the initial version? Or is there an alternative?

Thanks,

Kevin


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.