-->
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.  [ 4 posts ] 
Author Message
 Post subject: Group By and count elements
PostPosted: Tue Apr 04, 2006 7:13 am 
Newbie

Joined: Tue Mar 14, 2006 10:25 am
Posts: 5
Hello,

I have a collection property called "Rights" (ISet) with a "User" root object User. Im looking desesperately for a way to get an additionnal field
that would count the number of elements in my "Rights" Collection. I'd want also to have the User object as the returned parameter :

The following query don't seem to work, nhibernate claims for a more detailed description of User object.

Code:
select usr, count(rights) from User usr left join usr.Rights rights where usr.Name='myuser'
group by usr


gives the following exception :

System.ArgumentException: Item has already been added. Key in dictionary: 'usr' Key being added: 'usr'

Any idea ?

thanx in advance.

Sam



Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 1.0.2

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 11:15 am 
Newbie

Joined: Tue Mar 14, 2006 10:25 am
Posts: 5
Re,
my problem is related to this JIRA item : http://jira.nhibernate.org/browse/NH-528

I have voted. Is there any plan to correct this bug ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 3:32 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
There are other things that have higher priority right now. You can work around the bug by specifying all properties of your User object, i.e. 'group by usr.Property, usr.AnotherProperty, ...'.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 9:55 am 
Newbie

Joined: Tue Mar 14, 2006 10:25 am
Posts: 5
I have more that 40 fields, gloups
Anyway...


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