cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: HOW TO : Creating a SelectQuery has Expression like this?
Date Thu, 09 Feb 2012 09:44:05 GMT
> so I used Expression.fromString("Book.hit = OldBook.hit");

You are on the right track with this, but you need to get your path's right. Aside from using
aliases which is a separate topic, the general concept of expression paths is "they all must
be relative to the root entity of the SelectQuery".

So there is a relationship between Book and OldBook. Don't know what it is called, let's assume
it is "oldBookRelationship"... So then an expression can be built like this:

  Expression.fromString("hit = oldBookRelationship.hit");

Hope this helps.
Andrus

On Feb 9, 2012, at 12:33 PM, atomix wrote:

> I have another question regarding Expression in Cayenne :
> 
> I want my generated SQL like so :
> 
> *SELECT ** 
> *FROM *Book B1 
> *JOIN *OldBook B2 *ON *B1.id= B2.id
> *WHERE *B1.hit = B2.hit
> 
> so I used Expression.fromString("Book.hit = OldBook.hit");
> 
> ... but it's not affect anything to the generated SQL, even when the String
> is wrong!!!!??
> 
> Can anyone point me the way to do this kind of Query, not to metion
> SQLTemplate because I know the way to do so! 
> 
> Thank in advance!


Mime
View raw message