hibernate 映射视图  我在DAO里 使用HQL 查询   语句如下
select r.flop as flop, r.stoa as stoa, sum(r.flno) as flno," +
" sum(r.cmwt) as cmwt, sum(r.cmcn) as cmcn, sum(r.cmbn) as cmbn," +
" sum(r.cmvn) as cmvn, sum(r.exflno) as exflno, sum(r.excmwt) as excmwt," +
" sum(r.excmcn) as excmcn, sum(r.excmbn) as excmbn," +
" sum(r.excmvn) as excmvn from ReportInExUnitloadAllV r  where 1=1 "
使用了 函数 ,但我要给每个函数取个别名 别名要和 视图的字段名对应,要不无法别引用, 无法实现,
我查了好多资料都没解决 希望大侠们帮我解决一下 看看 是不是HQL  sum() 是不是不能 AS 别名啊。

解决方案 »

  1.   

    hibernate  他是取对象名的,就是说在ReportInExUnitloadAllV 找到相对的字段属性.楼主的写法是JDBC的,不是HIBERNATE的
      

  2.   


    String hql = "select uid,"
    + "sum(case postType when 'A' then sumTime else null end ) as a,"
    + "sum(case postType when 'B' then sumTime else null end ) as b, "
    + "sum(case postType when 'C' then sumTime else null end ) as c,"
    + "sum(case postType when 'D' then sumTime else null end ) as d "
    + "from view2 where 1=1 ";可以的