-->
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.  [ 4 posts ] 
Author Message
 Post subject: Annotation @Version for timestamp field with DB time
PostPosted: Tue Mar 25, 2008 4:38 am 
Newbie

Joined: Tue Mar 25, 2008 4:14 am
Posts: 7
Location: Israel
Hibernate version: 3.2, annotations version 3.3.1

Mapping documents: annotations

Name and version of the database you are using:Oracle 11i

Hello all.
I have used Hibernate before but I am new to annotations. I need to map a class to DB. In the class there is a Timestamp property which I would like to map to Date field in DB and I want to use @Version annotation on this field. It works fine but the time that is written to DB Date field is jvm time and not DB time. I could not find any way how to switch it to DB time with annotations. I do not want to use XML descriptor to override annotation, since I also use hbm mappings - plus I saw that documentation on XML descriptors is in poor state at the moment. I was forced to switch to hbm for my class and I used <version type="dbtimestamp",...></version>. This is working fine. Is there any way to get the same functionality with Annotations?

_________________
Best regards,
Michael Gantman


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 12:43 pm 
Newbie

Joined: Mon Jan 21, 2008 7:30 am
Posts: 9
I'm having the same problem... Want to specify dbtimestamp in my annotation but am finding it's not working!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 4:08 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

the db timestamp feature is Hibernate specific. Currently Hibernate Annotations only implements javax.persistence.Version which does not have a type attribute. I believe you will have to stick with xml if you want to keep this feature for now.

Retrieving the time from the db is also not supported by all databases and implies that for each increment the db needs to be accessed. If you are not working with a legacy db it is recommended to use a number for versioning.

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 15, 2008 8:45 am 
Newbie

Joined: Tue Mar 25, 2008 4:14 am
Posts: 7
Location: Israel
Thanks. Indeed we had to stay with xml for that reason. Thanks for reply though.

_________________
Best regards,
Michael Gantman


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