[size=medium][b][color=blue]近日发现HQL中, count()函数要求还比较严格,举例说:[/color][/b]
[/size]
[b]1、count(1)报错[/b]
[b]2、count(c.*)报错[/b]
[b]3、count(*)正确[/b]
[/size]
[b]1、count(1)报错[/b]
<query name="getRecordCountById">
select count(1) as recordCount from Km c
where c.id=:id
</query>
[b]2、count(c.*)报错[/b]
<query name="getRecordCountById">
select count(c.*) as recordCount from Km c
where c.id=:id
</query>
[b]3、count(*)正确[/b]
<query name="getRecordCountById">
select count(*) as recordCount from Km c
where c.id=:id
</query>