hibernate查询一条记录
- 作者: 愤怒的趣多多
- 来源: 51数据库
- 2020-09-29
部分代码:
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中,像你几十万条数据马上就内存溢出
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中,像你几十万条数据马上就内存溢出
推荐阅读