cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Gentry" <blackn...@gmail.com>
Subject Re: "Is" Expression
Date Wed, 30 Apr 2008 14:57:15 GMT
Andrus,

I was thinking "someBoolean = true" (or false) would work, but it
doesn't.  However, it does work if you evaluate the expression:

    expression = Expression.fromString("isActive = $value");
    parameters = new HashMap<String, Boolean>(1);
    parameters.put("value", Boolean.TRUE);
    query = new SelectQuery(TestBool.class,
expression.expWithParameters(parameters));

That worked just fine for me: WHERE t0.isActive = ? [bind: 1->isActive:'true']

Shouldn't a normal Expression.fromString() be allowed to specify "=
true" or "= false"?  Can't we internally convert true/false into
Boolean.TRUE/Boolean.FALSE?

/dev/mrg


On Tue, Apr 29, 2008 at 4:49 AM, Andrus Adamchik <andrus@objectstyle.org> wrote:
> Try this:
>
>   Expression expression = ExpressionFactory.matchExp("actif", Boolean.TRUE);
>
>  I don't remember how good was the boolean support in 2.0.x, but the above
> works for me with Cayenne 3.0 and MySQL 5 rather well.
>
>  Andrus
>
>
>
>
>  On Apr 29, 2008, at 11:34 AM, Support Technique C3T wrote:
>
>
> > Hi
> > I'm new with this great ORM and I'm looking for a way to select rows where
> a column is true.
> > I use Cayenne 2.0.4 with MySQL 5.0
> > I created a table with a boolean column. I inserted rows in it with
> Cayenne.
> >
> > But i wanted to select rows but I didn't find a ExpressionFactory method
> like that :
> > Expression expression = ExpressionFactory.isExp("actif", true);
> >
> > So I tried workarounds
> >
> > Expression expression = Expression.fromString("actif is true"); doesn't
> work
> >
> > I tried Expression expression = ExpressionFactory.matchExp("actif", "1") :
> that doesn't work
> >
> > neither Expression expression = Expression.fromString("actif == 1");
> >
> > Could youn help me ?
> >
> > Thank you
> >
> > Best regards
> >
> >
> >
>
>

Mime
View raw message