hibernate的求和怎么写?

wer719 2008-07-28 03:12:08
hibernate的求和怎么写?
hibernate的求和怎么写?
hibernate的求和怎么写?
...全文
285 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lx999501 2008-07-31
  • 打赏
  • 举报
回复
sum(xxxx)
guoyunsky 2008-07-29
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 Landor2004 的回复:]
Java codehql方法:
int sum =((Integer)session.createQuery("select sum(a.property1) from Xxx as a").uniqueResult();
criteria方法:
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Xxx.class);
int sum =(Integer)criteria.setProjection(Projections.sum("property1")).uniqueResult();
[/Quote]
Landor2004 2008-07-28
  • 打赏
  • 举报
回复
hql方法:
int sum =((Integer)session.createQuery("select sum(a.property1) from Xxx as a").uniqueResult();
criteria方法:
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Xxx.class);
int sum =(Integer)criteria.setProjection(Projections.sum("property1")).uniqueResult();
ee4456 2008-07-28
  • 打赏
  • 举报
回复
select num(字段名) form 类名
这就是了啊?

session.createQuery(),会返回一个object,你转成int或者Integer就是了,LS的就是对的
jishu_vip 2008-07-28
  • 打赏
  • 举报
回复
sum();
天外流星 2008-07-28
  • 打赏
  • 举报
回复


int sum =((Integer)hibsession.createQuery("select sum(a.cost) from CdrList as a").iterate().next()).intValue();

jyq0105 2008-07-28
  • 打赏
  • 举报
回复
sum()??
me old 2008-07-28
  • 打赏
  • 举报
回复
求和?什么意思?

67,537

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧