-->
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: HQL for all objects which contain an array element?
PostPosted: Thu Sep 06, 2007 3:17 pm 
Newbie

Joined: Thu Jul 27, 2006 11:36 am
Posts: 10
Hibernate version: 3.1.3

Mapping documents:
Code:
<hibernate-mapping default-cascade="none">
   <class name="org.sakaiproject.evaluation.model.EvalGroupNodes" table="EVAL_GROUPNODES"
      dynamic-insert="false" dynamic-update="false">
      <id name="id" type="java.lang.Long" unsaved-value="null">
         <column name="ID" />
         <generator class="native" />
      </id>
      <property name="lastModified" type="java.util.Date">
         <column name="LAST_MODIFIED" not-null="true" />
      </property>
      <!-- this should be the node id -->
      <property name="nodeId" type="java.lang.String" index="eval_group_nodeid">
         <column name="NODE_ID" not-null="true" length="255" />
      </property>
      <!-- this holds the associated list of eval groups for this node -->
      <array name="evalGroups" table="EVAL_GROUPNODES_GROUPS" cascade="all"><!-- all-delete-orphan -->
         <key column="ID" not-null="true" />
         <list-index column="GROUPS_INDEX" />
         <element type="string" column="GROUPS" not-null="true" />
      </array>
   </class>
</hibernate-mapping>


I need to do a query which will return the "org.sakaiproject.evaluation.model.EvalGroupNodes" which have a specific item in the evalGroups array. I cannot seem to figure out how to get this query to work.

I tried the following HQL:
Code:
select egn.nodeId from EvalGroupNodes egn where ? in egn.evalGroups order by egn.nodeId


but I just get this error (it seems to convert egn.evalGroups into "."):
org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not execute query; uncategorized SQLException for SQL [select evalgroupn0_.NODE_ID as col_0_0_ from EVAL_GROUPNODES evalgroupn0_, EVAL_GROUPNODES_GROUPS evalgroups1_ where evalgroupn0_.ID=evalgroups1_.ID and (? in (.)) order by evalgroupn0_.NODE_ID]; SQL state [37000]; error code [-11];

Can anyone help?
-AZ


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 5:46 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
have you tried this:

select egn.nodeId from EvalGroupNodes egn where ? in elements(egn.evalGroups) order by egn.nodeId


I am not really sure if it solves the problem but give it a try.


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.