We're updating the issue view to help you get more done. 

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

Status

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

3.5.4
4.0.0.CR3
3.6.0.Beta1

Priority

Minor