Hibernate - join un related objects
- by CuriousMind
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?