You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Mike Kienenberger <mk...@gmail.com> on 2006/04/24 15:32:49 UTC

Re: Newbie question:

On 4/23/06, Chad Smith <Ch...@ic2solutions.com> wrote:
> I have this syntax ...
>
> Expression q1 = ExpressionFactory.matchExp(Company.OWNER_ID_PROPERTY,
> userId);
> Expression q2 = ExpressionFactory.matchExp(Company.SHARED_FLAG_PROPERTY,
> "Y");
> q1.orExp(q2);
> select.andQualifier(q1);
>
> I want it to produce SQL that looks like this ...
>
> SELECT *
> FROM company
> WHERE (t0.owner_id = 'jsmith' OR t0.shared_flag = 'Y')
>
> ... the problem is the OR clause doesn't get appended
>
> btw: I don't want this syntax ...
>
> SELECT *
> FROM company
> WHERE (t0.owner_id = 'jsmith') OR (t0.shared_flag = 'Y')
>
> Can someone tell me what I'm doing wrong?

Just for reference for others reading this thread, the problem is that
"q1.orExp(q2);" returns a new expression -- it does not modify q1.  
Ie, you need q3 = q1.orExp(q2)