-->
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.  [ 5 posts ] 
Author Message
 Post subject: Column not found: x0_0_-Error when using having with count?
PostPosted: Thu Nov 27, 2003 7:03 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
Every Object has a Category and I'd like to select all categories that appear more than once in the database.
So I created a SQL-Call like this:

Query q = sess.createQuery(
"select ps.category from PersistentSource ps group by ps.category having count(ps.category) > 1"
);


when tyring to do this,hibernate Throws an Excaption:

Code:
11:58:54,981  WARN JDBCExceptionReporter:38 - SQL Error: -28, SQLState: S0022
11:58:54,981 ERROR JDBCExceptionReporter:46 - Column not found: x0_0_
11:58:54,981  WARN JDBCExceptionReporter:38 - SQL Error: -28, SQLState: S0022
11:58:54,981 ERROR JDBCExceptionReporter:46 - Column not found: x0_0_
11:58:54,997 ERROR JDBCExceptionReporter:38 - Could not execute query
java.sql.SQLException: Column not found: x0_0_
   at org.hsqldb.jdbcDriver.sqlException(Unknown Source)
   at org.hsqldb.jdbcDriver.sqlException(Unknown Source)
   at org.hsqldb.jdbcResultSet.findColumn(Unknown Source)



Can anybody give me a tip?
My mapping:
Code:
   <class name="de.abelssoft.syncom.model.repositories.PersistentSource" table="PERSISTENTSOURCE">
      <id name="id" type="integer" column="ID">
         <generator class="native"/>
      </id>
      <property name="url" column="URL" type="de.abelssoft.hibernate.MyUrlUserType"/>
      <property name="className" column="CLASSNAME" type="class"/>
      <property name="dateAdded" column="DATEADDED" type="calendar"/>
      <property name="lastUpdate" column="LASTUPDATE" type="calendar"/>
      <property name="lastChanged" column="LASTCHANGED" type="calendar"/>
      <property name="requests" column="REQUESTS" type="int"/>
      <property name="category" column="CATEGORY" type="string"/>
      <property name="outdatedAt" column="OUTDATEDAT" type="calendar"/>
      <property name="originalDataStream" column="ORIGINALDATASTREAM" type="string"/>
      <property name="searchtext" column="SEARCHTEXT" type="string"/>
      <property name="allObservers" column="ALLOBSERVERS" type="serializable"/>
      <property name="type" column="TYPE" type="serializable"/>
      <property name="concreteObject" column="CONCRETEOBJECT" type="serializable"/>
   </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 7:15 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What does the generated SQL look like?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 8:53 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
It says:

Code:
13:48:39,343 DEBUG QueryTranslator:198 - HQL: select ps.category from de.abelssoft.syncom.model.repositories.PersistentSource ps group by ps.category having count(ps.category) > 1
13:48:39,343 DEBUG QueryTranslator:199 - SQL: select persiste0_.CATEGORY as x0_0_ from PERSISTENTSOURCE persiste0_ group by  persiste0_.CATEGORY having (count(persiste0_.CATEGORY)>1 )
13:48:39,343 DEBUG BatcherImpl:192 - about to open: 0 open PreparedStatements, 0 open ResultSets
13:48:39,359 DEBUG BatcherImpl:226 - prepared statement get: select persiste0_.CATEGORY as x0_0_ from PERSISTENTSOURCE persiste0_ group by  persiste0_.CATEGORY having (count(persiste0_.CATEGORY)>1 )
13:48:39,359 DEBUG BatcherImpl:232 - preparing statement
13:48:39,406 DEBUG Loader:179 - processing result set
13:48:39,406 DEBUG Loader:335 - result row:
13:48:39,406 DEBUG JDBCExceptionReporter:36 - SQL Exception
java.sql.SQLException: Column not found: x0_0_
   at org.hsqldb.jdbcDriver.sqlException(Unknown Source)
[...]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 27, 2003 9:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, the SQL looks just perfect, doesn't it. HSQL problem?


Top
 Profile  
 
 Post subject: HSQL
PostPosted: Thu Nov 27, 2003 10:25 am 
Newbie

Joined: Wed Nov 19, 2003 6:06 am
Posts: 9
You're right.
It looks like a valid statement. I'll try to change the database.

Thanks a lot for the tip!


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