I have class structure as following
class ABC {
abcid;
name;
listOfXYZObjects;
}
class XYZ {
xyzid;
name;
}
Now I have configured above classes in hbm file. There is some data already stored in DB. I have abcId and xyzId with me and want to fetch only name fields of both classes in single HQL query.
Can any one guide me for above.
Assume your ABC is College and XYZ is Student. Using Criteria, we can get college name and student name as follows.
Output:
Hibernate: select this_.name as y0_, s1_.name as y1_ from College1 this_ inner join Student1 s1_ on this_.id=s1_.colg_id where this_.id=? and s1_.id=?
SCASC College——–Student1