You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Arkaitz <ar...@yahoo.com> on 2001/04/04 14:46:15 UTC

Criteria & OR

Hi,

Is it possible to do something like this SQL sentence with Criteria?

    SELECT FROM TABLE WHERE COLUMN1 LIKE 'X' OR COLUMN2 > 10 OR COLUMN2
    < 1000; 

I've read the Javadocs and part of the sourcecode for Criteria, but I'm
not smart enough figure it out by myself. Does anyone have a snippet to
do this kind of OR with Criteria?

Thanks in advance,
Arkaitz.

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


Re: Criteria & OR

Posted by John McNally <jm...@collab.net>.
You can place two or more criteria for the same column using Criterion
chaining which you have to use for OR anyway, so the Hashtable is not an
issue, though I do favor removing it (as a low priority).  I have posted
examples on how to do use OR before.  It is a bit verbose, so I am not
inclined to repeat myself.  But if anyone cares to give an example or
two, I will add it to the xdocs prompty, as I definitely need to form
better documentation habits.

John McNally

Daniel Rall wrote:
> 
> Arkaitz <ar...@yahoo.com> writes:
> 
> > Hi,
> >
> > Is it possible to do something like this SQL sentence with Criteria?
> >
> >     SELECT FROM TABLE WHERE COLUMN1 LIKE 'X' OR COLUMN2 > 10 OR COLUMN2
> >     < 1000;
> >
> > I've read the Javadocs and part of the sourcecode for Criteria, but I'm
> > not smart enough figure it out by myself. Does anyone have a snippet to
> > do this kind of OR with Criteria?
> 
> I believe that you currently need to do some sort of Criteria
> chaining, as last I checked the fact that Criteria extends Hashtable
> prevents putting two criteria for the same column name in the same
> Criteria object.  It would be much better if Criteria didn't extend
> Hashtable, and instead implemented some sort of AST structure
> internally.
> 
> Daniel
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

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


Re: Criteria & OR

Posted by Daniel Rall <dl...@collab.net>.
Arkaitz <ar...@yahoo.com> writes:

> Hi,
> 
> Is it possible to do something like this SQL sentence with Criteria?
> 
>     SELECT FROM TABLE WHERE COLUMN1 LIKE 'X' OR COLUMN2 > 10 OR COLUMN2
>     < 1000; 
> 
> I've read the Javadocs and part of the sourcecode for Criteria, but I'm
> not smart enough figure it out by myself. Does anyone have a snippet to
> do this kind of OR with Criteria?

I believe that you currently need to do some sort of Criteria
chaining, as last I checked the fact that Criteria extends Hashtable
prevents putting two criteria for the same column name in the same
Criteria object.  It would be much better if Criteria didn't extend
Hashtable, and instead implemented some sort of AST structure
internally.

Daniel

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