HQL-查询返回Object 类型 修改 返回对象

public List<SelectItem> PBingCount(Integer dbid) {
        // TODO Auto-generated method stub
        String sql = " select COUNT(t.ptypeid) value ,ty.typename name "+
                " from sheet_info i ,sheet_item t ,item_type ty "+
                " where t.ptypeid = ty.id and t.sheetid = i.id and i.delflag =1 ";
                if(dbid!=null){
                    sql+="and i.dbid=2 ";
                }
                sql+="GROUP BY t.ptypeid ,ty.typename ";
                NativeQuery query = super.getSession().createNativeQuery(sql);
                //指定返回对象类型
                 query.unwrap(NativeQueryImpl.class).setResultTransformer(Transformers.aliasToBean( SelectItem.class));
                return query.list();
    }

猜你喜欢

转载自blog.csdn.net/qq_35302923/article/details/81188394