【问题标题】:Using count(*) or count(s) on JPA QL在 JPA QL 上使用 count(*) 或 count(s)
【发布时间】:2012-08-18 08:59:44
【问题描述】:

我有一个 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) 只会计算时间 @ 987654323@ 不为空。但是,我怀疑 s.status cannot 在这里为空,尤其是在 where 之后,所以,即使那 的区别.. 但也许 count(status),如 @ 987654326@不是列,会更合适吗?

标签: hibernate jpa-2.0


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-02
  • 2012-12-31
  • 1970-01-01
  • 1970-01-01
  • 2019-07-02
  • 1970-01-01
  • 2011-05-01
相关资源
最近更新 更多