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 "Kollivakkam R. Raghavan" <rk...@cisco.com> on 2004/02/23 08:27:50 UTC

Query on collection descriptors

If I have a 1-n relationship between two entities represented as a
collection-descriptor in OJB, how can I use the PB Query API to retrieve
items in the collections based on some constraint on the n side of the
relationship.  In other words I don't want to get all the entries in the
collection but only the ones that satisfy the constraint.

For example:
If I had a classroom table and a student table which has a 1-n
relationship (each classroom has n students male or female), I want to
write a PB query that returns me all male (or female) students in a
given classroom (assume that gender is an attribute in the student
table).  Is this possible?

Thanks in advance
Raghavan


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


Re: Query on collection descriptors

Posted by Armin Waibel <ar...@apache.org>.
Hi Raghavan,

Kollivakkam R. Raghavan wrote:

> If I have a 1-n relationship between two entities represented as a
> collection-descriptor in OJB, how can I use the PB Query API to retrieve
> items in the collections based on some constraint on the n side of the
> relationship.  In other words I don't want to get all the entries in the
> collection but only the ones that satisfy the constraint.
> 

you can try to implement a QueryCustomizer
http://db.apache.org/ojb/tutorial3.html#Customizing collection queries

regards,
Armin

> For example:
> If I had a classroom table and a student table which has a 1-n
> relationship (each classroom has n students male or female), I want to
> write a PB query that returns me all male (or female) students in a
> given classroom (assume that gender is an attribute in the student
> table).  Is this possible?
> 
> Thanks in advance
> Raghavan
> 
> 
> ---------------------------------------------------------------------
> 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