[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 ?
|