-->
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: association query questions
PostPosted: Thu Jun 24, 2004 8:18 pm 
Newbie

Joined: Mon Jun 07, 2004 12:25 pm
Posts: 1
We are using 2.1.4. I am using QBC for querying. It works great for a single table and one to many off that table.

I have a few many-to-many relationships off this main table. It is a normal association. Person - linktable - Country table. The person can have many countries and countries can belong to many people.

I have a query form the user can enter Person attributes and QBC handles this (last name, first name, ..). In building this criteria to submit, if the user selects mulitple countries I want to add that in. I do not see how to do that for an association using the criteria.

Say they want to enter in the search form:
firstname= %B%
lastname= %K%
countries= United States, Canada, Mexico

Since I do not think I can do this by QBC I am looking for different ways to handle this. Any suggestion is helpful.

The current alg is:
if (lastname != null) criteria.add(Expression.like("lname", lastname)
if (firstname != null) criteria.add(Expression.like("fname",firstname)
and so on ...

but I wanted to add
if (countries.notempty() )
loop over selected countries
criteria.add(Expression.eq("country.countrylink.countryId", country[i]
end loop
end if

Of course I can not do the last part above b/c Hibernate knows nothign of that link as it is defined like that.
Can I not combine them?
Can I combine it using Expression.sql?
Can I not use QBC?
Should I use HQL or straight SQL?

Thanks
Kevin


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.