You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by fanyun <yu...@vtradex.com> on 2001/04/25 10:50:27 UTC

how to use Peer

Hi all:

Now I want to have a complex sql using Peer: 

	select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);

How can I build this sql by using  Peer and criteria?


Regards& Thanks 

fanyun

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by John McNally <jm...@collab.net>.
Obviously I did not test it either.  But I just modified Criterion to
allow chaining the and's and or's.

john mcnally

Eric Dobbs wrote:
> 
> On Thursday, April 26, 2001, at 11:51  AM, John McNally wrote:
> 
> > Criteria crit = new Criteria();
> > Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1,
> > Criteria.LESS_THAN);
> > Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2,
> > Criteria.GREATER_THAN);
> > Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5,
> > Criteria.GREATER_THAN);
> > Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3,
> > Criteria.LESS_THAN);
> >
> > crit.add( a1.and(b2).or(a5.and(b3)) );
> 
> a1.and() returns void
> and void.or() isn't going to work, right?
> 
> I think that has to be:
> a1.and(b2);
> a5.and(b3);
> a1.or(a5);
> crit.add(a1);
> 
> But I haven't actually tested it.
> -Eric
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by Eric Dobbs <er...@dobbse.net>.
On Thursday, April 26, 2001, at 11:51  AM, John McNally wrote:

> Criteria crit = new Criteria();
> Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1,
> Criteria.LESS_THAN);
> Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2,
> Criteria.GREATER_THAN);
> Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5,
> Criteria.GREATER_THAN);
> Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3,
> Criteria.LESS_THAN);
>
> crit.add( a1.and(b2).or(a5.and(b3)) );

a1.and() returns void
and void.or() isn't going to work, right?

I think that has to be:
a1.and(b2);
a5.and(b3);
a1.or(a5);
crit.add(a1);

But I haven't actually tested it.
-Eric

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by John McNally <jm...@collab.net>.
Criteria crit = new Criteria();
Criteria.Criterion a1 = crit.getNewCriterion(ABC.A, 1,
Criteria.LESS_THAN);
Criteria.Criterion b2 = crit.getNewCriterion(ABC.B, 2,
Criteria.GREATER_THAN);
Criteria.Criterion a5 = crit.getNewCriterion(ABC.A, 5,
Criteria.GREATER_THAN);
Criteria.Criterion b3 = crit.getNewCriterion(ABC.B, 3,
Criteria.LESS_THAN);

crit.add( a1.and(b2).or(a5.and(b3)) );


john mcnally


fanyun wrote:
> 
> Hi:
> 
> Thanks for all of your helps. I have read the Criteria ,  BasePeer source
> code carefully. To my understanding the criterion can be used to solve the
> multipal use of one field.
> 
> But if I want to do a:
> 
>         select * from abc where (a < 1 and b > 2)  or  (  a > 5  and b < 3)
> 
> I can not find out how to build this sql by using Peers.
> 
> If it is possible to build the sql, if any one can give me an sample, it
> will be very helpful.
> 
> Regards&Thanks
> 
> fanyun
> 
> (BTW,  now my way to do this is use the  Criteria.CUSTOM method.  I really
> do not like this, because it bring in the sql syntex into my code)
> 
> -----Original Message-----
> From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
> Sent: Thursday, April 26, 2001 1:50 AM
> To: turbine-user@jakarta.apache.org
> Subject: Re: how to use Peer
> 
> see the documentation.  there is an advanced criteria page with
> examples.
> 
> john mcnally
> 
> fanyun wrote:
> >
> > Hi all:
> >
> > Now I want to have a complex sql using Peer:
> >
> >         select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);
> >
> > How can I build this sql by using  Peer and criteria?
> >
> > Regards& Thanks
> >
> > fanyun
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


RE: how to use Peer

Posted by fanyun <yu...@vtradex.com>.
Hi:

Thanks for all of your helps. I have read the Criteria ,  BasePeer source
code carefully. To my understanding the criterion can be used to solve the
multipal use of one field.

But if I want to do a:

	select * from abc where (a < 1 and b > 2)  or  (  a > 5  and b < 3)

I can not find out how to build this sql by using Peers.

If it is possible to build the sql, if any one can give me an sample, it
will be very helpful.


Regards&Thanks

fanyun

(BTW,  now my way to do this is use the  Criteria.CUSTOM method.  I really
do not like this, because it bring in the sql syntex into my code)



-----Original Message-----
From: jmcnally [mailto:jmcnally]On Behalf Of John McNally
Sent: Thursday, April 26, 2001 1:50 AM
To: turbine-user@jakarta.apache.org
Subject: Re: how to use Peer


see the documentation.  there is an advanced criteria page with
examples.

john mcnally

fanyun wrote:
>
> Hi all:
>
> Now I want to have a complex sql using Peer:
>
>         select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);
>
> How can I build this sql by using  Peer and criteria?
>
> Regards& Thanks
>
> fanyun
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by John McNally <jm...@collab.net>.
see the documentation.  there is an advanced criteria page with
examples.

john mcnally

fanyun wrote:
> 
> Hi all:
> 
> Now I want to have a complex sql using Peer:
> 
>         select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);
> 
> How can I build this sql by using  Peer and criteria?
> 
> Regards& Thanks
> 
> fanyun
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by Daniel Rall <dl...@finemaltcoding.com>.
Jon Stevens <jo...@latchkey.com> writes:

> on 4/25/01 1:50 AM, "fanyun" <yu...@vtradex.com> wrote:
> 
> > Hi all:
> > 
> > Now I want to have a complex sql using Peer:
> > 
> > select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);
> > 
> > How can I build this sql by using  Peer and criteria?
> > 
> 
> Criterion

Which is an inner class of Critiera.


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: how to use Peer

Posted by Jon Stevens <jo...@latchkey.com>.
on 4/25/01 1:50 AM, "fanyun" <yu...@vtradex.com> wrote:

> Hi all:
> 
> Now I want to have a complex sql using Peer:
> 
> select * from ABC where ( a = 1 or a = 2)  and (b = 1  or b =2);
> 
> How can I build this sql by using  Peer and criteria?
> 

Criterion

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org