Here q1 and q2 don't behave the same (which is strange as its been interchangeably used in the hibernate reference document).
The query q1 works fine for tables where one has 'single column' primary key, but for tables having composite keys this breaks as follows:
Hibernate: select count((employee0_.NAME, employee0_.AGE)) as col_0_0_ from Employee employee0_ [Here 'Name' and 'Age' form the composite key for Employee]
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: ORA-00907: missing right parenthesis
Looks like for q1 it counts the primary key, which will definitely fail in case of composite key.
Hope this helps
Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both