Friday, August 10, 2012

How to get fields from different tables in hibernate ?



StringWriter queryS = new StringWriter(200);
Query query;

queryS.append("SELECT A.dateBilling,B.currencyCode " );
queryS.append(" from AImpl A,BImpl B ");
queryS.append("where B.id = A.id  " );


query = this.getSession().createQuery(queryS.toString());
//The values in this array are:
//dateBilling     = results[0]
//currencyCode = results[1]
Object[] results = (Object[]) query.list().get(0);

return results;

No comments:

Post a Comment