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.  [ 1 post ] 
Author Message
 Post subject: Returning 2 objects per row in a named query
PostPosted: Fri Jan 20, 2006 4:50 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
[b]Hibernate version:2.1.8[/b]

Most of my named queries return a single mapped object per row. These named queries are of course in the hbm.xml files.

Is it possible, in a named query in the hbm.xml file, to return 2 mapped objects per row ??

For example, object A has a one to many assocation to object B.

Currently, I have a named query in the mapping file for object B that returns instances of object B. This named query I use in a servlet. The servlet then calls instanceOfB.getA() for each item in the list returned from the named query.

Thus, I made:
1) 1 call to the database to execute the named query returning N objects.
2) N calls to the database to get the A association for each B, where N is the number of Bs returned.


In the named query that is defined in the hbm.xml file, if I can return B and A at the same time in one row, then I would only have 1 database call returning N objects ... each row having an instance of B and an instance of A.

Is this possible ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.