-->
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: HQL and set elements
PostPosted: Mon Mar 21, 2005 8:07 pm 
Newbie

Joined: Wed Mar 09, 2005 1:50 pm
Posts: 6
Hibernate version:3

Mapping documents:see below

Name and version of the database you are using:MySQL(latest)


I have an object mapping that contains two sets as follows:

....<class....(owningClass)>....

<set name="b"
lazy="false"
table="b"
sort="unsorted"
inverse="false"
optimistic-lock="true">
<key column="a_ID" on-delete="noaction" />
<element type="string" column="bName"
not-null="false" unique="false" />
</set>

<set name="c"
lazy="false"
table="c"
sort="unsorted"
inverse="false"
optimistic-lock="true">
<key column="a_ID" on-delete="noaction" />
<element type="string" column="cName"
not-null="false" unique="false" />
</set>


....</class>


I am trying to write a query to return the objects of the owning class such that:

((owningClass.id = a.a_ID and a.aName=?) OR
(owningClass.id = b.a_ID and b.bName=?))


I have something like...
<query name="a.getAsForbNameOrcName"><![CDATA[
select a
from A a inner join a.b ar inner join a.c au
where ((a.id = ar.a_ID) and (ar.bName = ?)) or
((a.id = au.a_ID) and (au.cName = ?))
]]></query>

I have also tried....

<query name="a.getAsForbNameOrcName"><![CDATA[
select a
from A a
where ((a.id = a.b.a_ID) and (a.b.bName = ?)) or
((a.id = a.c.a_ID) and (a.c.cName = ?))
]]></query>


I always get....

"org.hibernate.QueryException: cannot dereference scalar collection element: a_ID ....."


Any help would be appreciated.


Seamus


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.