[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5093) CriteriaQuery using count leads to wrong query

Jesper Steen Møller (JIRA) noreply at atlassian.com
Sat Apr 17 20:37:58 EDT 2010


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5093?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36483#action_36483 ] 

Jesper Steen Møller commented on HHH-5093:
------------------------------------------

FWIW, I tried adding this test case in org.hibernate.ejb.criteria.basic.BasicCriteriaUsageTest under 3.5.1:

	public void testCountWalls()
	{
		EntityManager em = getOrCreateEntityManager();
		em.getTransaction().begin();
	
		CriteriaBuilder cb= em.getCriteriaBuilder();
		CriteriaQuery<Long> cq = cb.createQuery(Long.class);
		Root<Wall> u = cq.from(Wall.class);
		cq.select(cb.count(u));
		em.createQuery( cq ).getSingleResult();
		// We are checking for bad SQL here!

		em.getTransaction().commit();
		em.close();
	}

This was in the Hibernate tests, running against HSQL.
Worked just fine, the generated SQL was:
    select
        top ? count(wall0_.id) as col_0_0_ 
    from
        crit_basic_wall wall0_

> CriteriaQuery using count leads to wrong query
> ----------------------------------------------
>
>                 Key: HHH-5093
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5093
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager
>    Affects Versions: 3.5.0-Final
>            Reporter: Frederic Müller
>
> Using "query.select(cb.count(root));" we get a query like this:
> select count() from test.Entity as generatedAlias0 left join generatedAlias0.message as generatedAlias1
> Tried almost everything but this problem doesn't seem to have been addressed for quite some time now. 
> Seems like some other people still have the same problem and yet nobody seems to bother.
> https://forum.hibernate.org/viewtopic.php?p=2428452

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       



More information about the hibernate-issues mailing list