[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5419) COUNT operator with composite primary key and JPA 2.0 Criteria API produces bad sql
Ståle W. Pedersen (JIRA)
noreply at atlassian.com
Mon Mar 12 09:26:49 EDT 2012
[ https://hibernate.onjira.com/browse/HHH-5419?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=45911#comment-45911 ]
Ståle W. Pedersen commented on HHH-5419:
----------------------------------------
hi, i created a test case that confirm that count query with EmbeddedId use all Id's in the argument. the test also do a count for a class using ClassId which create a sql that only use one Id.
I havent figured out how to fetch the sql to the test, so you have to view the log to confirm atm.
https://github.com/stalep/hibernate-orm/commit/54911765de7981ec9a2318fc9928be68ff37bab3
> COUNT operator with composite primary key and JPA 2.0 Criteria API produces bad sql
> -----------------------------------------------------------------------------------
>
> Key: HHH-5419
> URL: https://hibernate.onjira.com/browse/HHH-5419
> Project: Hibernate ORM
> 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.CR4, 4.0.0.CR5
>
> 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