-->
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: Retrieving identifier of associated object
PostPosted: Fri Mar 30, 2007 10:10 am 
Newbie

Joined: Sun Jan 14, 2007 2:52 pm
Posts: 19
Regarding http://www.hibernate.org/118.html#A21
Does the placement of annotations affect calling getId() and if it triggers a database select?
We have placed all our annotations on fields. Should calling
Code:
Long itemId = bid.getItem().getId();

cause a select statement?
Is it a requirement that you put the annotations on the accessor method if you wish to be able to obtain ids without database access?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 6:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
yes
Try to set @AccessType("property") on your @Id fields, this might do the trick

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 30, 2007 6:28 pm 
Newbie

Joined: Sun Jan 14, 2007 2:52 pm
Posts: 19
Thanks Emmanuel.
I had looked at the documentation for @AccessType but was a little unclear on how it works. If I use @AccessType("property") whilst still having all the annotations set on fields, will it read the annotations and go through the getters and setters, or will it just use the getters as if there were no annotations and use default settings?

We have rewritten all the annotations now to be placed on getters but it is still interesting to know.


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.