I have two tables ABC, XYZ, i have taken their join on three common columns let’s say P,Q,R.
Now,
I want the response of query to be the complete joined row.
Session hibernateSession = (Session) em.getDelegate();
StringBuffer queryString = new StringBuffer();
queryString.append("SELECT t1.*, t2.* FROM ABC t1, XYZ t2 WHERE t1.P = t2.P AND t1.Q = t2.Q AND t1.R = t2.R");
Collection<----> results = query.list();
Do I need to create a new object which can store the complete join row or is there any way I can transform the result into two collections i.e. Collection<ABC> , Collection<XYZ>.
Please help me out, I am new to hibernate.
Thanks
you can use
addEntitymethod on query object, like thisSee http://docs.jboss.org/hibernate/core/3.3/reference/en/html/querysql.html#d0e13763
You may want to read about
ResultTransformerswhich will be useful when working with native SQL queries.