Hibernate - join un related objects

Posted by CuriousMind on Stack Overflow See other posts from Stack Overflow or by CuriousMind
Published on 2010-12-26T12:19:18Z Indexed on 2010/12/26 19:54 UTC
Read the original article Hit count: 179

Filed under:
|

I have a requirement, wherein I have to join two unrelated objects using Hibernate HQL. Here is the sample POJO class

class Product{
int product_id;        
String name;
String description;
}

and

Class Item{
int item_id;
String name;
String description;
int quantity;
int product_id; //Note that there is no composed product object.
}

Now I want to perform a query like select * from Product p left outer join Item i on p.product_id = i.item_id

I want a multidimensional array as an output of this query so that I can have separate instances of Product and Item, instead of one composed in another. Is there any way to do this in Hibernate?

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about hql