COUNT operator with composite primary key and JPA 2.0 Criteria API produces bad sql

Description

Hibernate produces a invalid SQL if anyone use the count() operator with the JPA 2.0 Criteria API. Code:

CriteriaBuilder cb = getEntityManager().getCriteriaBuilder();
CriteriaQuery<Object[]> cq = cb.createQuery(Object[].class);
Root<EntityCompositePK> r = cq.from(EntityCompositePK.class);

cq.multiselect(cb.count(r));
assertEquals(0, ((Long) (getEntityManager().createQuery(cq).getSingleResult())[0]).intValue());

I'm sending a little maven project which reproduces the bug.

Environment

hibernate-entitymanager 3.6.0.Beta1, glassfish 3.0.1, linux ubuntu 10.04, MS SQL Server 2008

Attachments

Assignee

JohnV

Reporter

Fabio Oliveira

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Minor
Configure