Hi Bryan,
On Oct 29, 2004, at 6:50 PM, Bryan Lewis wrote:
> Expression statusValuesExp =
> ExpressionFactory.inExp("tradeStatus.oid", types);
Try this - it should work and get rid of the join:
ExpressionFactory.inExp("tradeStatus", types);
This advise is really in the category of Cayenne hacks, not features
(it is an ununtended consequence of a particular qualifier translator
implementation). I even had to to try this myself first, before
recommending on the list, as I wasn't sure how it will behave. Also
this will likely work only for single-join relationships.
Answering your other question - why is this so hard, all I can do is to
mention a proverbial "object relational impedance". I.e. a tree of
objects is a very different data structure from a relational schema.
For example in your case you are building an *object* expression. So
from the Java standpoint if a TradeSource Java class doesn't have a
"TradeStatus_ID" property, you can't match on that property. Related
class TradeStatus does, so you have to get that related object first,
and then match its property...
The more I look at the bigger picture, the more I think that "db:"
expressions is a reasonable workaround to get to the underlying
relational structure. So there is nothing bad in using them to tweak
the queries.
Andrus
This archive was generated by hypermail 2.0.0 : Fri Oct 29 2004 - 20:02:36 EDT