You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Hugi Thordarson <hu...@karlmenn.is> on 2016/03/25 17:45:04 UTC
Expression for checking if a to-many relationship contains an object
Hi all!
Subject says it all, really. How do I write an Expression to fetch all records where a to-many relationship contains an object.
For example, let’s say a “Person” entity has a to-many relationship to an “Employment" entity, which is then linked to a “Company” entity. And I want to fetch all “Person” records that are linked to a certain company record.
Cheers,
- hugi
Re: Expression for checking if a to-many relationship contains an object
Posted by Hugi Thordarson <hu...@karlmenn.is>.
> On 25. mar. 2016, at 17:46, Andrus Adamchik <an...@objectstyle.org> wrote:
>
>
>> On Mar 25, 2016, at 7:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>>
>> Hi all!
>>
>> Subject says it all, really. How do I write an Expression to fetch all records where a to-many relationship contains an object.
>>
>> For example, let’s say a “Person” entity has a to-many relationship to an “Employment" entity, which is then linked to a “Company” entity. And I want to fetch all “Person” records that are linked to a certain company record.\
>
> Something like "employments.company = $company" should work. This results in simple joins across to-many, and should give you what you need.
Of course. Works like a charm, thanks!
- hugi
Re: Expression for checking if a to-many relationship contains an object
Posted by Andrus Adamchik <an...@objectstyle.org>.
> On Mar 25, 2016, at 7:45 PM, Hugi Thordarson <hu...@karlmenn.is> wrote:
>
> Hi all!
>
> Subject says it all, really. How do I write an Expression to fetch all records where a to-many relationship contains an object.
>
> For example, let’s say a “Person” entity has a to-many relationship to an “Employment" entity, which is then linked to a “Company” entity. And I want to fetch all “Person” records that are linked to a certain company record.\
Something like "employments.company = $company" should work. This results in simple joins across to-many, and should give you what you need.
Andrus