-->
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.  [ 3 posts ] 
Author Message
 Post subject: count in hibernate
PostPosted: Wed Mar 24, 2010 4:01 pm 
Newbie

Joined: Wed Mar 03, 2010 6:27 am
Posts: 11
Hi all,
I am making a web application using hibernate and got an issue couldnt solve it yet,
I want make a query look like
SELECT message_id, COUNT(*) FROM message GROUP BY user_id ORDER BY message_id
how can I do that hibernate?
session.createQuery("...");
thanks...


Top
 Profile  
 
 Post subject: Re: count in hibernate
PostPosted: Thu Mar 25, 2010 3:28 am 
Newbie

Joined: Wed Feb 18, 2009 5:07 am
Posts: 8
Can you run this plain SQL?

I don't know how you can select message_id, count() but group by user_id instead of group by message_id.

What is the error if you put the plain SQL in session.createQuery("...")?


Top
 Profile  
 
 Post subject: Re: count in hibernate
PostPosted: Thu Mar 25, 2010 3:59 am 
Regular
Regular

Joined: Wed Mar 10, 2010 4:48 am
Posts: 106
try count() instead of COUNT().


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.