hibernate createSqlQuery 多表查询 没有返回预期对象数组问题
代码如下:
String sql = " select wk.a1 ,wk.a2 , {ex.*} from " + " (select distinct a1,a2 from A ) as wk join mms_cell {ex} on {ex}.a1= wk.a1 " + " order by wk.a1,wk.a2,{ex}.mydate"; Query query = getSession().createSQLQuery(sql). addEntity("ex",User.class); List<Object[]> list = query.list();
Query query = getSession().createSQLQuery(sql).addScalar("a1",Hibernate.STRING).addScalar("a2",Hibernate.STRING). addEntity("ex",User.class);