用户登录
用户注册

分享至

hibernate查询记录数

  • 作者: -老衲要射了
  • 来源: 51数据库
  • 2020-10-06
部分代码:
String hql="select * from table where ……";
List list=query.list();
int count=(Integer)list.get(0);//总记录数
==========补充
不好意思,写错了 是select count(*) from table where ……"; 绝对是不能String hql="select * from table where ……";这么写的,这么写就是吧整张表的数据放入query中,像你几十万条数据马上就内存溢出



  你可以把你这个表再给描述的清楚点么?进度数量是什么是五种商品的各自的总数量么?

select (select count(*) from table where kind=a)as a,
(select count(*) from table where kind=b)as b,
(select count(*) from table where kind=c)as c,
(select count(*) from table where kind=d)as d,
(select count(*) from table where kind=e)as e
from table
软件
前端设计
程序设计
Java相关