db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andras Balogh <and...@reea.net>
Subject Re: How does Criteria.or work??
Date Wed, 14 Jul 2004 06:38:43 GMT
Hello,

I don't know about criteria.or but you may try to do it with 
Criteria.Criterion
See:
http://db.apache.org/torque/criteria-howto.html
section "Using Criterion to use a Column twice in a Criteria"

Best regards,
Andras.

Daniel de los Reyes wrote:

> Hello,
>
> I am trying to make a query that may look like this :
>
> SELECT *  FROM visibilidadevento WHERE
>   visibilidadevento.IDPERSONAPRIMERAEJEC=40 OR
>   visibilidadevento.IDAREAORIGEN=20         OR
>   visibilidadevento.IDPROYECTO=100          OR
>   visibilidadevento.HISTAREAID=10
> ORDER BY visibilidadevento.IDEVENTO DES
>
> (Watch the OR's)
>
> In orther to get it, I am using Criteria this way :
>
> crit.or(VisibilidadeventoPeer.IDPERSONAPRIMERAEJEC, 
> params.getPersonId(), Criteria.EQUAL );
>                 crit.or(VisibilidadeventoPeer.IDAREAORIGEN, 
> params.getUserArea(), Criteria.EQUAL );
>
> crit.add(VisibilidadeventoPeer.IDPROYECTO, params.getCbmcproyecto(), 
> Criteria.EQUAL );
>                 crit.or(VisibilidadeventoPeer.HISTAREAID, 
> params.getUserArea(), Criteria.EQUAL );
>
> crit.addDescendingOrderByColumn(VisibilidadeventoPeer.IDEVENTO);   
>
>
> However when Torque generates the query, all OR's get replaced by 
> AND's!!!
>
> SELECT *  FROM visibilidadevento WHERE 
> visibilidadevento.IDPERSONAPRIMERAEJEC=40 AND 
> visibilidadevento.IDAREAORIGEN=20 AND visibilidadevento.IDPROYECTO=100 
> AND visibilidadevento.HISTAREAID=10 ORDER BY 
> visibilidadevento.IDEVENTO DES
>
> I have read Torque's docs about Criteria.OR and it says :
>
> This method adds a new criterion to the list of criterias. If a 
> criterion for the requested column already exists, it is "OR"ed to the 
> existing criterion.
>
> Does this mean I can't have an OR whith a single ocurrence of a table 
> column?
>
> How can this be done?
>
>
>


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


Mime
View raw message