You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Support Technique C3T <su...@c3t.fr> on 2008/04/29 10:34:54 UTC
"Is" Expression
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
Re: "Is" Expression
Posted by Andrus Adamchik <an...@objectstyle.org>.
Looking at the code, looks like it only works as a standalone
condition, e.g. "a = 1 and true":
https://issues.apache.org/cayenne/browse/CAY-696
So yeah, boolean literals are not supported as condition operands :-/
> Anyone else encountering an SVN issue right now?
It's been up and down today - the new SVN machine is still being
tweaked for production load by infra. It works for me now, although
seems pretty slow.
Andrus
On Apr 30, 2008, at 6:24 PM, Michael Gentry wrote:
> No, I'm pretty current (I updated here sometime last week). I just
> rebuilt and re-ran and still see the same issue. It is dying in
> Expression.fromString() -- it bails on the false in "isActive = false"
> (or true):
>
> org.apache.cayenne.exp.parser.ParseException: Encountered "false" at
> line 1, column 12.
> Was expecting one of:
> "(" ...
> "+" ...
> "-" ...
> "$" ...
> "obj:" ...
> "db:" ...
> <NULL> ...
> <PROPERTY_PATH> ...
> "\'" ...
> "\"" ...
> <INT_LITERAL> ...
> <FLOAT_LITERAL> ...
>
> You can see it specifically listed a $ there, which is probably why
> "isActive = $value" parsed.
>
> On a different topic, I know there were SVN issues a few days ago. I
> just tried to update and see this:
>
> [11:12:08] ~/Projects/Eclipse/Cayenne30> svn update
> svn: PROPFIND request failed on '/repos/asf/cayenne/main/trunk'
> svn: PROPFIND of '/repos/asf/cayenne/main/trunk': Could not create SSL
> connection through proxy server (https://svn.apache.org)
>
Andrus
Re: "Is" Expression
Posted by Michael Gentry <bl...@gmail.com>.
No, I'm pretty current (I updated here sometime last week). I just
rebuilt and re-ran and still see the same issue. It is dying in
Expression.fromString() -- it bails on the false in "isActive = false"
(or true):
org.apache.cayenne.exp.parser.ParseException: Encountered "false" at
line 1, column 12.
Was expecting one of:
"(" ...
"+" ...
"-" ...
"$" ...
"obj:" ...
"db:" ...
<NULL> ...
<PROPERTY_PATH> ...
"\'" ...
"\"" ...
<INT_LITERAL> ...
<FLOAT_LITERAL> ...
You can see it specifically listed a $ there, which is probably why
"isActive = $value" parsed.
On a different topic, I know there were SVN issues a few days ago. I
just tried to update and see this:
[11:12:08] ~/Projects/Eclipse/Cayenne30> svn update
svn: PROPFIND request failed on '/repos/asf/cayenne/main/trunk'
svn: PROPFIND of '/repos/asf/cayenne/main/trunk': Could not create SSL
connection through proxy server (https://svn.apache.org)
Anyone else encountering an SVN issue right now?
Thanks!
On Wed, Apr 30, 2008 at 11:08 AM, Andrus Adamchik
<an...@objectstyle.org> wrote:
>
> On Apr 30, 2008, at 5:57 PM, Michael Gentry wrote:
>
>
> > 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?
> >
>
> IIRC Tore added boolean constant parsing to 3.0 some time ago. I could be
> wrong of course. Are you on 2.0.x?
>
> Andrus
>
Re: "Is" Expression
Posted by Tore Halset <ha...@pvv.ntnu.no>.
On 30. april. 2008, at 17.08, Andrus Adamchik wrote:
> IIRC Tore added boolean constant parsing to 3.0 some time ago. I
> could be wrong of course. Are you on 2.0.x?
That was true/false as an expression element, not as a value. See jira
for examples.
http://issues.apache.org/cayenne/browse/CAY-696
- Tore.
Re: "Is" Expression
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Apr 30, 2008, at 5:57 PM, Michael Gentry wrote:
> 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?
IIRC Tore added boolean constant parsing to 3.0 some time ago. I could
be wrong of course. Are you on 2.0.x?
Andrus
Re: "Is" Expression
Posted by Michael Gentry <bl...@gmail.com>.
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 <an...@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
> >
> >
> >
>
>
Re: "Is" Expression
Posted by Andrus Adamchik <an...@objectstyle.org>.
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
>
>