qq_26373023 2016-03-31 04:00 采纳率: 9.1%
浏览 1339
已结题

关于hql语句查询的问题

select information,count(information) from Information information where 1=1 group by information.id;
请问这hql语句合法么,Information是个视图,同时也有这个实体类~想查询出这个information对象,并且算出个数

  • 写回答

3条回答

  • 聪明的一休丶 2016-03-31 04:33
    关注

    select information,count(information) from Information information where 1=1 group by information.id;问题很多
    直接select * from information; 条数就是 结果集的大小.size();
    然后说你的语法问题:
    select information,count(information) from Information information 。。。。。这句话问题很多仔细看
    where 1=1 group by information.id;后半句 where 1=1;有必要么? group by不应该这么用
    information.id这样的结果是唯一的,而且应该在 where后面 。。。。
    单独查询条数可以用 select count(information) from Information;
    查询所有用 select * from Information ;返回的是List ,,,个数就是 size()

    评论

报告相同问题?