[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-5419) COUNT operator with composite primary key and JPA 2.0 Criteria API produces bad sql
John Verhaeg (JIRA)
noreply at atlassian.com
Thu Oct 20 17:49:19 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5419?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
John Verhaeg resolved HHH-5419.
-------------------------------
Resolution: Fixed
Fix Version/s: 4.0.0.CR4
Modified HQL rendering of COUNT function so that when a non-distinct entity with an ID is specified as a parameter, it renders a star instead of the ID attribute(s). This allows for greater support across DBs, since some do not support the previous rendering of multiple ID attributes when the ID happens to be a composite ID.
> COUNT operator with composite primary key and JPA 2.0 Criteria API produces bad sql
> -----------------------------------------------------------------------------------
>
> Key: HHH-5419
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5419
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.5.4, 3.6.0.Beta1, 4.0.0.CR3
> Environment: hibernate-entitymanager 3.6.0.Beta1, glassfish 3.0.1, linux ubuntu 10.04, MS SQL Server 2008
> Reporter: Fabio Braga de Oliveira
> Assignee: John Verhaeg
> Priority: Minor
> Fix For: 4.0.0.next, 4.0.0.CR4
>
> Attachments: hibernate-count-bug.zip
>
>
> 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.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list