Hibernate关于聚合函数的一些用法
2008-10-27 22:24
417 查看
关于hibernate中聚合函数的用法
1. public int countDetails() throws Exception {
// TODO Auto-generated method stub
Transaction trans = null;
trans = HibernateSessionFactory.getSession().beginTransaction();
int m =(Integer)HibernateSessionFactory.getSession().createQuery(
"select count(*) from Details").list().get(0);
trans.commit();
HibernateSessionFactory.closeSession();
return m;
}
返回数据总行数
2.public double countDetailsMoney() throws Exception {
Transaction trans = null;
trans = HibernateSessionFactory.getSession().beginTransaction();
Double m =(Double)HibernateSessionFactory.getSession().createQuery(
"select sum(money) from Details").list().get(0);
trans.commit();
HibernateSessionFactory.closeSession();
return m;
}
计算总金额
1. public int countDetails() throws Exception {
// TODO Auto-generated method stub
Transaction trans = null;
trans = HibernateSessionFactory.getSession().beginTransaction();
int m =(Integer)HibernateSessionFactory.getSession().createQuery(
"select count(*) from Details").list().get(0);
trans.commit();
HibernateSessionFactory.closeSession();
return m;
}
返回数据总行数
2.public double countDetailsMoney() throws Exception {
Transaction trans = null;
trans = HibernateSessionFactory.getSession().beginTransaction();
Double m =(Double)HibernateSessionFactory.getSession().createQuery(
"select sum(money) from Details").list().get(0);
trans.commit();
HibernateSessionFactory.closeSession();
return m;
}
计算总金额
相关文章推荐
- 自己最近总结了下关于VI的一些基本用法
- 关于数据库里cascade的用法,在MySQL和Hibernate是不同的
- 关于数据库里cascade的用法,在MySQL和Hibernate是不同的
- 关于hibernate的一些恶心的小地方报错(持续更新)
- Spring MVC的一些关于请求的注解用法详解
- 关于struct的一些用法
- 关于Ubuntu下apt的一些用法及和yum的比较
- 一些关于Hibernate延迟加载的误区
- 关于git的一些用法
- 关于sqlite的一些基本用法
- 关于self.用法的一些总结
- 关于cin、gets等输入的一些用法
- 关于枚举的一些用法
- 关于正则表达式的一些用法
- 关于sqlplus用法的一些总结
- 关于-webkit-的一些用法
- 关于Ubuntu下apt的一些用法及和yum的比较
- 关于Ubuntu下apt的一些用法及和yum的比较
- 关于self.用法的一些总结
- 关于VML一些用法的注意事项