-->
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.  [ 1 post ] 
Author Message
 Post subject: not able to group by object alonside aggregate function
PostPosted: Wed Sep 21, 2005 1:17 am 
Newbie

Joined: Wed Oct 08, 2003 7:42 pm
Posts: 18
Hibernate version: 2.1.8

Full stack trace of any exception that occurs:

21/09/2005 14:31:05 net.sf.hibernate.util.JDBCExceptionReporter
SEVERE: ERROR: column "accountdat0_.accounttype" must appear in the GROUP BY clause or be used in an aggregate function

Problem definition:
I am having problem with grouping by an object in a query. As far as I know this is not achievable automatically. e.g. SELECT account, sum(trx.amount)
from account join account.trx as trx group by account"

when I attempt group this manually I run into problems with foreign keys as I do not have access to them as properties.

e.g. SELECT account, sum(trx.amount) from account
join account.trx as trx group by account.id, account.name, account.accounttype, account.accounttype.id, account.accounttype.name"

I was hoping that the "account.accounttype" would resolve to the foreign key but infact it resolves to the id of the accounttype (account.accounttype.id)

Is there a way that I can achieve this grouping? Any help is greatly appreciated.


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

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.