You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Thomas Herbst <Th...@b-s-s.de> on 2003/10/08 18:20:32 UTC

Query Criterias and relations PROBLEM!!

hi,

i have a 1:n relationship between Person an Phones.

if i make the following query to persons, i get all persons with a phonenumber like "052*"

crit = new Criteria();
crit.addLike("phones.number", "052*"); 
query = new QueryByCriteria(Person.class, crit);

thats ok!

but when if i make a 

person.getPhones();

i get all phone numbers of the person and not only these numbers that match to the query criteria that i need!!

is there any solution??????

regards thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Query Criterias and relations PROBLEM!!

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi thomas,

this is pretty much normal behaviour !
the first query looks for all persons having a phonenumber like "052*" 
and returns these persons. when you do person.getPhones() all phones 
belonging to this ONE person are returned, no matter what the number is 
(at least one is like "052*").

hth
jakob

Thomas Herbst wrote:
> hi,
> 
> i have a 1:n relationship between Person an Phones.
> 
> if i make the following query to persons, i get all persons with a phonenumber like "052*"
> 
> crit = new Criteria();
> crit.addLike("phones.number", "052*"); 
> query = new QueryByCriteria(Person.class, crit);
> 
> thats ok!
> 
> but when if i make a 
> 
> person.getPhones();
> 
> i get all phone numbers of the person and not only these numbers that match to the query criteria that i need!!
> 
> is there any solution??????
> 
> regards thomas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org