当前位置: 代码迷 >> Web前端 >> Hibernate(HQL) 奇异的count()函数
  详细解决方案

Hibernate(HQL) 奇异的count()函数

热度:587   发布时间:2012-08-29 08:40:14.0
Hibernate(HQL) 怪异的count()函数
近日发现HQL中, count()函数要求还比较严格,举例说:


1、count(1)报错
<query name="getRecordCountById">
	select count(1) as recordCount from Km c
	where c.id=:id
</query>



2、count(c.*)报错
<query name="getRecordCountById">
	select count(c.*) as recordCount from Km c
	where c.id=:id
</query>


3、count(*)正确
<query name="getRecordCountById">
	select count(*) as recordCount from Km c
	where c.id=:id
</query>


  相关解决方案