-->
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: HQL (Searching) for "Any" type mappings
PostPosted: Tue Jul 20, 2004 11:03 am 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
Folks,

I would like to search "Requisition" via Client's attribute (e.g. code). This should be a simple one, however, I haven't been able to find any information about this, anyone can help?

<!--
Sample HBM
-->
<class name="Requisition"
table="requisition"
optimistic-lock="version"
>
...
<any name="Client" id-type="string" meta-type="string">
<meta-value value="1" class="InternalClient"/>
<meta-value value="2" class="ExternalClient"/>
<column name="client_type"/>
<column name="client_id"/>
</any>
...
</class>

Thanks in advance,

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 11:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You need to do a where-clause (theta-style) join.


Code:
from Requisition r, Client c
where r.Client.id = c.id and ....


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 5:50 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
select count(*) from Requisition as r, client as c where r.client.id = c.id

-> net.sf.hibernate.QueryException: unexpected token


select count(*) from Requisition as r, r.client as c where r.client.id = c.id

-> Hibernate: select count(*) as x0_0_ from requisition requisitionv0_ where (requisitionv0_.client_id=requisitionv0_.objId )
(it does not join to the table of "InternalClient" or "ExternalClient")

P.S.
Typo for my previous posting:
<any name="Client"
<any name="client"

Any thoughts?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 2:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
r.client.id = c.id

i think id is a protected keyword

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 21, 2004 5:58 pm 
Beginner
Beginner

Joined: Tue Mar 23, 2004 8:40 pm
Posts: 22
Anthony, do you mind to explore a bit ...


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.