These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Thu Nov 19, 2009 1:29 pm 
Newbie

Joined: Thu Nov 19, 2009 1:21 pm
Posts: 5
According to the website, I'm supposed to post here for bugs first. So be it.

So here goes. Using the following JPA 2.0 Query constructor, I want to do the equivalent to:

"select count(u) from User u;"

I've confirmed with Linda, the JPA 2.0 spec person at Sun that the code for that should look like this:

public void CountUsers(EntityManager em)
{

CriteriaBuilder cb= em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<User> u = cq.from(User.class);
cq.select(cb.count(u));
}

Internally, Hibernate generates this string
select count() from com.example.User as generatedAlias0
but then kvetches about the ) as an org.hibernate.hql.ast.QuerySyntaxException.

Pierce


Top
 Profile  
 
 Post subject: Re: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Tue Dec 15, 2009 6:36 am 
Newbie

Joined: Mon Dec 14, 2009 5:27 pm
Posts: 7
When experimenting with Hibernate 3.5 and JPA 2.0, I hit exactly the same problem: hibernate builds "select count() ...." query and then fails on it. Have you found any workarounds for this, or should we just sit and wait for next hibernate 3.5 version release?


Top
 Profile  
 
 Post subject: Re: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Tue Dec 15, 2009 1:27 pm 
Newbie

Joined: Thu Nov 19, 2009 1:21 pm
Posts: 5
3.5.0-SNAPSHOT fixes it.


Top
 Profile  
 
 Post subject: Re: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Wed Feb 03, 2010 12:28 pm 
Newbie

Joined: Mon Dec 14, 2009 5:27 pm
Posts: 7
We've just plugged in Hibernate 3.5 Beta 4. Looks like exactly the same error happens... Did you have better luck with it?


Top
 Profile  
 
 Post subject: Re: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Thu Apr 08, 2010 6:19 am 
Newbie

Joined: Mon Aug 17, 2009 12:54 pm
Posts: 2
I have the same problem after releasing the final version Hibernate 3.5.0.
Can anybody help and give the solution?


Top
 Profile  
 
 Post subject: Re: [JPA 2.0][3.5-Beta-2] Bug with Typed Queries and count
PostPosted: Sat Apr 17, 2010 8:33 pm 
Newbie

Joined: Thu Apr 15, 2010 9:29 pm
Posts: 4
This must somehow be related to the User class or SQL dialect -- I tried this on 3.5.1 with HSQL and it worked just fine.

Could you post a short example which demonstrates the error?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.