Re: Query Examples Needed � Expression.fromString() syntax?

From: Eric Lazarus (ericllazaru..ahoo.com)
Date: Wed May 24 2006 - 15:45:29 EDT

  • Next message: Jeff de Vries: "Re: Caching problem?"

    Thank you, Michael and Joshua!

    What about efficiency? If I want to "and" in a bunch
    of things, like as many as 10 things if the user fills
    in all the fields of the web query form, then it would
    look like this? :

    Expression e =
    ExpressionFactory.greaterExp("estimatedPrice", new
    BigDecimal(100000.0));

    e = e.and( ExpressionFactory.lessExp("estimatedPrice",
    new
    BigDecimal(5000.0)) );

    e = e.and( ExpressionFactory.lessExp("productSize",
    BigDecimal(100.0) );

    e = e.and( ExpressionFactory.lessExp("productWeight",
    new
    BigDecimal(200.0)) );

    I can just keep appending conditions on like this?
    Will this turn into efficient SQL code if done this
    way? If not, what is the best way?

    Thanks,

    Eric

    --- Joshua Pyle <joshua.t.pyl..mail.com> wrote:

    > I never use fromString any more.
    >
    > But using the expressionFactory to and and or
    > expressions is very simple...
    >
    > Expression e =
    > ExpressionFactory.greaterExp("estimatedPrice", new
    > BigDecimal(100000.0));
    >
    > e = e.and(
    > ExpressionFactory.lessExp("estimatedPrice", new
    > BigDecimal(5000.0)) );
    >
    > --
    > Joshua T. Pyle
    > Go has always existed.
    >
    > On 5/24/06, Eric Lazarus <ericllazaru..ahoo.com>
    > wrote:
    > > Would anyone reply with some nice examples of
    > > SelectQuery beside the simple one here:
    > >
    > >
    >
    http://www.objectstyle.org/cayenne/userguide/dataobjects/dataobjects-example.html
    > >
    > > Expression e =
    > > ExpressionFactory.greaterExp("estimatedPrice",
    > > new BigDecimal(100000.0))
    > >
    > > I need to do things with ANDS and ORs and I'm not
    > sure
    > > how to use expression factory (or should I use
    > > Expression.fromString() ?) to do it.
    > >
    > > Right now my immediate need is to be able to
    > construct
    > > a query with an arbitary number of possible "and"
    > > clauses depending on what the user types.
    > >
    > > Seems like fromString() is going to be easy and
    > > powerful but I can't find an example of the syntax
    > > using google.
    > >
    > > Even just a few nice examples would be helpful.
    > >
    > > Can I look at the attributes of sub objects using
    > this
    > > syntax? How?
    > >
    > > Thanks!
    > >
    > > Eric
    > >
    > >
    > > __________________________________________________
    > > Do You Yahoo!?
    > > Tired of spam? Yahoo! Mail has the best spam
    > protection around
    > > http://mail.yahoo.com
    > >
    >
    >
    > --
    > Joshua T. Pyle
    > Go has always existed.
    >

    __________________________________________________
    Do You Yahoo!?
    Tired of spam? Yahoo! Mail has the best spam protection around
    http://mail.yahoo.com



    This archive was generated by hypermail 2.0.0 : Wed May 24 2006 - 15:45:53 EDT