[... Taking this to cayenne-user list, since it really belongs there...]
Hi Matt,
just like Mike said, if you need to reference related objects in
qualifier, just use relationships. This is no different from EOF:
DataObject relatedObject...;
Expression qualifier = ExpressionFactory.matchExp("toRelatedObject",
relatedObject);
List objects = context.performQuery(new SelectQuery(MyClass.class,
qualifier);
No FK involved.
Andrus
On Apr 23, 2004, at 10:46 AM, Mike Kienenberger wrote:
> Matt Kerr <mat..entralparksoftware.com> wrote:
>> i have a situation (for better or worse)
>> where i'm querying the database against an fk value.
>> it's only a problem because i have a relationship built on top of that
>> fk column.
>>
>> it seems like although cayenne is aware of the fk columns,
>> it's not completely supporting them - ?
>>
>> i would like to reference the fk by _PROPERTY name when building the
>> qualifier/expression -
>> and i end up adding this to my impl :-( ...
>
> Querying by a foreign key value is like querying by a primary key
> value. It
> can be done, but it's not encouraged. Instead, you should just be
> following the relationship.
>
> If you have a Contact record with an Address fk, you should be using
> aContact.getAddress() to look up the address record.
>
> If you're just looking up arbitrary Address records, it's not a
> foreign key
> issue, it's a primary key issue for the Address table.
>
This archive was generated by hypermail 2.0.0 : Fri Apr 23 2004 - 11:05:40 EDT