iteye_10087
2009-10-30 22:39
浏览 544
已采纳

getHibernateTemplate().find(queryString) 返回的是什么对象?

String queryString = "from BClass";
   return getHibernateTemplate().find(queryString);

 

 

String queryString = "select cid as CODE , className as NAME from BClass";
   return getHibernateTemplate().find(queryString);

 

 

 

上面第一个返回的是包含BClass的List,那第二个的写法返回的是什么对象呢?

 

 

 


问题补充:
要怎么把它映射为haspmap呢?
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • CaiHuajiang 2009-10-31 00:06
    已采纳

    hql多表查询

    (1)String hql = "select new map(a.CUId as CUId,a.unitName as unitName,b.CUFId as CUFId,b.UFName as UFName) from PhCorrelativeUnit a,PhCorrelativeUnitFunction b where a.CUId=b.CUId";

    List list = this.getHibernateTemplate().find(hql);

    多个表的字段放到map中,map的键值就是as后面的别名,如果没有as就是字段名

    (2) String hql = "select new com.phantom.appeal.action.bean.DealPaper(a.id as id,a.billId as billId,a.state as state,a.creator as creator,a.createtime as createtime ,b.eventContent as eventContent ,c.realName as realName,b.billCode as billCode,b.citName as citName ) from PhDealBill a,PhAcceptBill b,PhUser c where a.departmentId="+ billid+ " and a.state=0 and a.billId=b.billId and a.creator =c.userId order by a.billId";

    return this.getHibernateTemplate().find(hql);

    另外就是写一个类,对应你要查询的字段,这里的类名是new com.phantom.appeal.action.bean.DealPaper,里面对应查询的字段名

    [url]http://spring028.iteye.com/blog/233669[/url]

    评论
    解决 无用
    打赏 举报
  • 查看更多回答(1条)

相关推荐 更多相似问题