-->
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: id of lazy property
PostPosted: Wed Aug 06, 2008 11:16 am 
Newbie

Joined: Wed Jul 02, 2008 7:54 am
Posts: 8
Location: Brussels
I'm sure there're alot of topics on this subject, but impossible to find them.

I have a many-to-one relation but I don't want to load the related object, I just want to retrieve it id. What's the property for?

Thank you in advance

Oolon


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 06, 2008 11:35 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Just the property you specified in the mapping file for the id.

_________________
--Wolfgang


Top
 Profile  
 
 Post subject: Re: id of lazy property
PostPosted: Tue Jun 30, 2009 5:43 am 
Newbie

Joined: Thu Jun 25, 2009 7:22 am
Posts: 9
I have the same problem. Just to make sure you understand me consider this example:
I have a persistent class A
Code:
class A {
  private B b;
  ...
}

and b shall be lazy, because I don't need b very often.
In my application I want to retrieve a large list of objects of type A to print them. In this case I also want to print the id of b. Hibernate already knows about the id of b, but it's hidden in hibernate's wrapper class for B, called B_$$_javassist_3. Is there a way to get to this hidden id without accessing the database again? I mean calling a.getB().getId() would be possible but would entail unnecessary effort and would take very long in my case. I also know about the solution of using SQL or HQL queries not to retrieve the persistent A objects as objects but as list of properties. But IMO that's not very comfortable.

Any ideas how to get to the hidden id of an lazy property?
Thanks in advance.


Top
 Profile  
 
 Post subject: Re: id of lazy property
PostPosted: Tue Jun 30, 2009 5:55 am 
Newbie

Joined: Thu Jun 25, 2009 7:22 am
Posts: 9
OK, I'm sorry for my last post. It's as easy as it should be. You can just call a.getB().getId() and hibernate is not going the retrieve the whole object b.
I think in my first test I forgot the getId() and printed a.getB() which forced hibernated to query the database for b. -> My fault.

So, let's end this thread with the word SOLVED :)


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.