Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 在JPA QL上使用计数(*)或计数_Hibernate_Jpa 2.0 - Fatal编程技术网

Hibernate 在JPA QL上使用计数(*)或计数

Hibernate 在JPA QL上使用计数(*)或计数,hibernate,jpa-2.0,Hibernate,Jpa 2.0,我有一个JPA查询来获取记录计数,但它显示org.hibernate.hql.QueryExecutionRequestException。问题是 @NamedQuery(name = "StudyplanCategory.findCountByStatus", query = "SELECT count(s) FROM StudyplanCategory s WHERE s.status =:status") 请帮助。您需要选择计数(*)。 见文件 我不使用JPA,而且已经很晚了,所以请看它

我有一个JPA查询来获取记录计数,但它显示org.hibernate.hql.QueryExecutionRequestException。问题是

@NamedQuery(name = "StudyplanCategory.findCountByStatus", query = "SELECT count(s) FROM StudyplanCategory s WHERE s.status =:status")
请帮助。

您需要选择计数(*)。 见文件

我不使用JPA,而且已经很晚了,所以请看它的价值:它在“普通SQL”中做了一些不同的事情。。在普通SQL中,
count(col)
将只计算次数
col
不为空。但是,我怀疑
s.status
在这里不能为null,尤其是在where之后,所以,即使这是区别。。但是,
count(status)
,因为
s
不是列,可能更合适?