You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Fabio Daprile <fa...@wuerth-phoenix.com> on 2003/02/18 11:51:36 UTC
Problem on building WHERE conditions with Criteria object!
Hello,
i'm trying to write a complex query builder for my application, using
Criteria and Criterions.
I'm dealing with this kind of query:
SELECT FROM Versions b, TicketVersions a, Tickets
WHERE (b.DESCRIPTION='PB_INC5' OR (b.DESCRIPTION='PB_INC4') AND
(a.VERSIONTYPE='Raised'))
AND Tickets.ID=a.TICKETID
AND a.VERSIONID=b.ID
this is built from this page of code:
_criteria.addAlias("a", TicketversionsPeer.TABLE_NAME);
_criteria.addAlias("b", VersionsPeer.TABLE_NAME);
_criteria.addJoin(TicketsPeer.ID, "a.TICKETID");
_criteria.addJoin("a.VERSIONID", "b.ID");
_criterion =
_criteria.getNewCriterion("b.DESCRIPTION",
"PB_INC5" ,
Criteria.EQUAL);
_criterion1 =
_criteria.getNewCriterion("b.DESCRIPTION",
"PB_INC4",
Criteria.NOT_EQUAL);
_criterion2 =
_criteria.getNewCriterion("a.VERSIONTYPE",
"Raised",
Criteria.EQUAL);
_criterion3 = _criterion.or(_criterion1);
_criterion4 = _criterion3.and(_criterion2)
i would expect the following SQL condition:
(b.DESCRIPTION='PB_INC5' OR b.DESCRIPTION='PB_INC4') AND
(a.VERSIONTYPE='Raised')
but i get this, quite different:
(b.DESCRIPTION='PB_INC5' OR (b.DESCRIPTION='PB_INC4') AND (a.VERSIONTYPE='Raised'))
somebody can tell me how to correctly set parenthesis order in the criterion?
thx in advance,
Fabio Daprile
************************************
Würth Phoenix S.r.l.
Fabio Daprile
Via Kravogl 4
I-39100 Bolzano
Phone: +39 0471 564111 (direct 564066)
Fax: +39 0471 564122
mailto:fabio.daprile@wuerth-phoenix.com
http:// www.wuerth-phoenix.com
*************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Problem on building WHERE conditions with Criteria object!
Posted by Eric Emminger <er...@ericemminger.com>.
Fabio
> > i'm trying to write a complex query builder for my application, using
> > Criteria and Criterions.
> > I'm dealing with this kind of query:
I suggest asking the torque-user list.
Eric
--
Eric Emminger
eric@ericemminger.com
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: Problem on building WHERE conditions with Criteria object!
Posted by Fabio Daprile <fa...@wuerth-phoenix.com>.
Hello,
for more complete information, i'm using jar torque-3.0-b2-dev.jar.
I've seen in the archives that there have been discussions on complex
queries with criteria in the past.
Some proposals have been made to include a Connector object to solve
this problem,
for example have a look at this link
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg00684.html
These changes have been accepted, in which jar?
thx
Fabio Daprile
Fabio Daprile wrote:
> Hello,
>
> i'm trying to write a complex query builder for my application, using
> Criteria and Criterions.
> I'm dealing with this kind of query:
>
> SELECT FROM Versions b, TicketVersions a, Tickets
> WHERE (b.DESCRIPTION='PB_INC5' OR (b.DESCRIPTION='PB_INC4') AND
> (a.VERSIONTYPE='Raised'))
> AND Tickets.ID=a.TICKETID
> AND a.VERSIONID=b.ID
>
> this is built from this page of code:
>
> _criteria.addAlias("a",
> TicketversionsPeer.TABLE_NAME);
> _criteria.addAlias("b", VersionsPeer.TABLE_NAME);
>
> _criteria.addJoin(TicketsPeer.ID, "a.TICKETID");
> _criteria.addJoin("a.VERSIONID", "b.ID");
>
> _criterion =
> _criteria.getNewCriterion("b.DESCRIPTION",
> "PB_INC5" ,
>
> Criteria.EQUAL);
> _criterion1 =
> _criteria.getNewCriterion("b.DESCRIPTION",
> "PB_INC4",
>
> Criteria.NOT_EQUAL);
> _criterion2 =
> _criteria.getNewCriterion("a.VERSIONTYPE",
> "Raised",
>
> Criteria.EQUAL);
>
> _criterion3 = _criterion.or(_criterion1);
> _criterion4 = _criterion3.and(_criterion2)
>
> i would expect the following SQL condition:
>
> (b.DESCRIPTION='PB_INC5' OR b.DESCRIPTION='PB_INC4') AND
> (a.VERSIONTYPE='Raised')
>
> but i get this, quite different:
>
> (b.DESCRIPTION='PB_INC5' OR (b.DESCRIPTION='PB_INC4') AND
> (a.VERSIONTYPE='Raised'))
> somebody can tell me how to correctly set parenthesis order in the
> criterion?
>
> thx in advance,
>
> Fabio Daprile
>
>
> ************************************
> Würth Phoenix S.r.l.
> Fabio Daprile
>
> Via Kravogl 4
> I-39100 Bolzano
> Phone: +39 0471 564111 (direct 564066)
> Fax: +39 0471 564122
> mailto:fabio.daprile@wuerth-phoenix.com
> http:// www.wuerth-phoenix.com
> *************************************
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
--
************************************
Würth Phoenix S.r.l.
Fabio Daprile
Via Kravogl 4
I-39100 Bolzano
Phone: +39 0471 564111 (direct 564066)
Fax: +39 0471 564122
mailto:fabio.daprile@wuerth-phoenix.com
http:// www.wuerth-phoenix.com
*************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org