sql查询转换成实体或对应的VO Transformers
//addScalar("id") 默认查询出来的id是全部大写的(sql起别名也无效,所以使用.addScalar("id")就可以自动填充类里面的id属性了,比较方便。
Query query = getSession().createSQLQuery(sql).addScalar("id");
query.setResultTransformer(Transformers.aliasToBean(Plan.class));
return query.list();
//说明t.line_name as lineName,之所以起别名是因为属性是lineName,当然别名起LINENAME也行是不区分大小写的
String hql = "select t.id,t.line_name as lineName from T t where t.ORGANIZ_ID in ("+orgaIdInTj+") ";
Query query = getSession().createSQLQuery(sql).addScalar("id").addScalar("LineName");