-->
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.  [ 2 posts ] 
Author Message
 Post subject: SQLServerDialect GROUP BY problem
PostPosted: Mon Jan 08, 2007 6:30 am 
Newbie

Joined: Wed Aug 30, 2006 5:57 am
Posts: 3
Hibernate version: 3.2.1

Mapping documents:

<class name="Utente" table="utente" >
<id name="id" type="int">
<column name="IdUtente" />
<generator class="assigned" />
</id>
<property name="userName" type="string">
<column name="UserName" length="20" not-null="true" />
</property>
<property name="password" type="string">
<column name="Password" length="50" not-null="true" />
</property>

</class>

Full stack trace of any exception that occurs:

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Column 'utente0_.UserName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.



Name and version of the database you are using: SQL Server 2000

The generated SQL (show_sql=true):

select
utente0_.IdUtente as IdUtente27_,
utente0_.UserName as UserName27_,
utente0_.Password as Password27_
from
ster.dbo.utente utente0_
group by
utente0_.IdUtente



the error occur when i use the following HQL query:

from Utente utente group by utente

the problem is that the select correctly select all the field of the Utente class, but the group by not.

Is Hibernete that is wrong or i made some error ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 6:58 am 
Newbie

Joined: Wed Aug 30, 2006 5:57 am
Posts: 3
probably my error,

at page 152 of the hibernate manual i'va found this

Quote:
Note that neither the group by clause nor the order by clause may contain arithmetic expressions. Also note
that Hibernate currently does not expand a grouped entity, so you can't write group by cat if all properties of

cat are non-aggregated. You have to list all non-aggregated properties explicitly.



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