Konrad,

your query could be expressed in quite some ways, but here's one way it could be done.

select p from Person p where p.courses.id = 1 or p.courses.id = 2

Apart from this, you could use the IN operator, but here I have to pass on the syntax 
as I am not really familiar ... 8-(. But maybe somebody else can help 
?

I hope this helps a little bit ...

Regards
Werner

On Wed, 11 Feb 2004 21:29:04 -0800 (PST), Konrad wrote:

>
>Hello.
>
>In Castor, how would I peform an OQL query that
>queries against a certain property of a collection of
>objects belonging to another object?
>
>For example, say I have the following classes:
>
>Person
>------
>id
>name
>courses   <- ArrayList that holds several Courses
>
>Course
>------
>id
>name
>category  
>
>
>The tables would look as follows:
>
>
>Person
>------
>id
>name
>
>
>Person_Course
>-------------
>id
>person_id
>course_id
>comment
>
>
>Course
>------
>id
>name
>
>
>Given this scenario, how would I find all the Persons
>that have certain courses?
>
>For example, if I have course1(id=1) and course2(id=2)
>are the Courses, how would I find all the People that
>are signed up for both Courses?
>
>Is the below the proper OQL for querying certain
>attributes of the objects in the collection?
>
>select p from Person p where p.courses=(new ArrayList
>containing course1 and course2??)
>
>Thank you very much.
>
>__________________________________
>Do you Yahoo!?
>New Yahoo! Photos - easier uploading and sharing.
>http://photos.yahoo.com/
>
>----------------------------------------------------------- 
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
>        unsubscribe castor-dev
>

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to