-->
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: How to retrieve an object by query without loading it
PostPosted: Thu Mar 30, 2006 5:52 am 
Beginner
Beginner

Joined: Fri Oct 07, 2005 5:35 am
Posts: 38
Location: France
Hi,

I try to get a reference to an B object by a query (not on its PK) and then I just need set the reference of B to A.
Code:
Query q = ..."select b from B as b, where b.x=..."
a.setB(q.getSingleResult());

It it possible to get an object by query without loading it ?(same kind of features as EntityManager.gerReference)

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 3:46 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Hmmm ... I don't think you can get a proxy out of the HQL query.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 31, 2006 8:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
select b.id

session.load(B.class, (Serializable) q.uniqueResult());

_________________
Emmanuel


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.