You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Robert Coup <rc...@ec.auckland.ac.nz> on 2003/12/08 05:28:57 UTC

Persistence Broker 'NOT' Criteria

Hi all,

I find the PB Query interface nice to use, and we're wrapping it on the UI side
of our application to allow users to do some simple querying. Then I ran into a
small problem - there is no addNotCriteria! :)

Since you need AND, OR, and NOT to make any boolean expression it seems a bit
strange that it isn't in there...

and while you can do:
  A.a=1 and A.b!=1 and A.c!=1
you can't 'not' a whole sub-criteria:
  A.a=1 and NOT (A.b=1 or A.c=1)

Was there any particular reason that it was left out, or any easy work-around
bearing in mind the query structure could be a lot more complex than my example?

OTOH, where would I look to add it? From my brief glance around Criteria I would
need to add another Type, but the code to go from Criteria to SQL i didn't find...

Thanks,

Rob :)


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


Re: Persistence Broker 'NOT' Criteria

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi robert,

you're the first ! the feature was not requested before. please file a 
feature request in scarab.
i'll have a look at it.

jakob

Robert Coup wrote:

> Hi all,
> 
> I find the PB Query interface nice to use, and we're wrapping it on the UI side
> of our application to allow users to do some simple querying. Then I ran into a
> small problem - there is no addNotCriteria! :)
> 
> Since you need AND, OR, and NOT to make any boolean expression it seems a bit
> strange that it isn't in there...
> 
> and while you can do:
>   A.a=1 and A.b!=1 and A.c!=1
> you can't 'not' a whole sub-criteria:
>   A.a=1 and NOT (A.b=1 or A.c=1)
> 
> Was there any particular reason that it was left out, or any easy work-around
> bearing in mind the query structure could be a lot more complex than my example?
> 
> OTOH, where would I look to add it? From my brief glance around Criteria I would
> need to add another Type, but the code to go from Criteria to SQL i didn't find...
> 
> Thanks,
> 
> Rob :)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


Re: Persistence Broker 'NOT' Criteria

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi antonio,


Antonio Gallardo wrote:

> Jakob Braeuchi dijo:
> 
>>hi antonio,
>>
>>the parameter could be used to mark the whole criteria 'negative'. there
>>would be no special addNot-method:
>>
>>Criteria crit1 = new Criteria();
>>crit1.addEqualTo("field1","test1");
>>crit1.addEqualTo("field2","test1");
>>crit1.setNegative(true);
> 
> 
> 
> The point is: I can use after the above code:
> 
> crit1.setNegative(false);
> 
> Then:
> 
> where (field1=test1 and field2=test2)
> 
> Is this correct?

yes, this is what i meant.

jakob
> 
> Best Regards,
> 
> Antonio Gallardo
> 
> 
>>Criteria crit2 = new Criteria();
>>crit2.addEqualTo("field3","test3");
>>crit2.addEqualTo("field4","test4");
>>
>>crit1.addOr(crit2);
>>
>>result :
>>
>>select ... where NOT(field1=test1 and field2=test2) OR (field3=test3 AND
>>  field4=test4)
>>
>>jakob
>>
>>Antonio Gallardo wrote:
>>
>>>Jakob Braeuchi dijo:
>>>
>>>
>>>>hi robert,
>>>>
>>>>what do you think about a 'NOT'-flag in the criteria ?
>>>>
>>>>Criteri crit = new Criteria();
>>>>
>>>>crit.addEqualTo("field1","test1");
>>>>crit.addEqualTo("field2","test1");
>>>>crit.setNegative(true);
>>>
>>>
>>>[RT]
>>>
>>>Is important to have the parameter in setNegative()? I guess, this is
>>>because we can turn it off later. Right?
>>>
>>>I think when we build a criteria we already know if it would negative or
>>>not. In that case the parameter is not needed at all.
>>>
>>>But maybe, in some special situation, someone can need to reverse the
>>>setNegative() effect in the criteria. In this case the param is needed.
>>>
>>>This are just random thoughts about this topic.
>>>
>>>Best Regards,
>>>
>>>Antonio Gallardo
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


Re: Persistence Broker 'NOT' Criteria

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Jakob Braeuchi dijo:
> hi antonio,
>
> the parameter could be used to mark the whole criteria 'negative'. there
> would be no special addNot-method:
>
> Criteria crit1 = new Criteria();
> crit1.addEqualTo("field1","test1");
> crit1.addEqualTo("field2","test1");
> crit1.setNegative(true);


The point is: I can use after the above code:

crit1.setNegative(false);

Then:

where (field1=test1 and field2=test2)

Is this correct?

Best Regards,

Antonio Gallardo

>
> Criteria crit2 = new Criteria();
> crit2.addEqualTo("field3","test3");
> crit2.addEqualTo("field4","test4");
>
> crit1.addOr(crit2);
>
> result :
>
> select ... where NOT(field1=test1 and field2=test2) OR (field3=test3 AND
>   field4=test4)
>
> jakob
>
> Antonio Gallardo wrote:
>> Jakob Braeuchi dijo:
>>
>>>hi robert,
>>>
>>>what do you think about a 'NOT'-flag in the criteria ?
>>>
>>>Criteri crit = new Criteria();
>>>
>>>crit.addEqualTo("field1","test1");
>>>crit.addEqualTo("field2","test1");
>>>crit.setNegative(true);
>>
>>
>> [RT]
>>
>> Is important to have the parameter in setNegative()? I guess, this is
>> because we can turn it off later. Right?
>>
>> I think when we build a criteria we already know if it would negative or
>> not. In that case the parameter is not needed at all.
>>
>> But maybe, in some special situation, someone can need to reverse the
>> setNegative() effect in the criteria. In this case the param is needed.
>>
>> This are just random thoughts about this topic.
>>
>> Best Regards,
>>
>> Antonio Gallardo


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


Re: Persistence Broker 'NOT' Criteria

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi antonio,

the parameter could be used to mark the whole criteria 'negative'. there 
would be no special addNot-method:

Criteria crit1 = new Criteria();
crit1.addEqualTo("field1","test1");
crit1.addEqualTo("field2","test1");
crit1.setNegative(true);

Criteria crit2 = new Criteria();
crit2.addEqualTo("field3","test3");
crit2.addEqualTo("field4","test4");

crit1.addOr(crit2);

result :

select ... where NOT(field1=test1 and field2=test2) OR (field3=test3 AND 
  field4=test4)

jakob

Antonio Gallardo wrote:
> Jakob Braeuchi dijo:
> 
>>hi robert,
>>
>>what do you think about a 'NOT'-flag in the criteria ?
>>
>>Criteri crit = new Criteria();
>>
>>crit.addEqualTo("field1","test1");
>>crit.addEqualTo("field2","test1");
>>crit.setNegative(true);
> 
> 
> [RT]
> 
> Is important to have the parameter in setNegative()? I guess, this is
> because we can turn it off later. Right?
> 
> I think when we build a criteria we already know if it would negative or
> not. In that case the parameter is not needed at all.
> 
> But maybe, in some special situation, someone can need to reverse the
> setNegative() effect in the criteria. In this case the param is needed.
> 
> This are just random thoughts about this topic.
> 
> Best Regards,
> 
> Antonio Gallardo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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


Re: Persistence Broker 'NOT' Criteria

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Jakob Braeuchi dijo:
> hi robert,
>
> what do you think about a 'NOT'-flag in the criteria ?
>
> Criteri crit = new Criteria();
>
> crit.addEqualTo("field1","test1");
> crit.addEqualTo("field2","test1");
> crit.setNegative(true);

[RT]

Is important to have the parameter in setNegative()? I guess, this is
because we can turn it off later. Right?

I think when we build a criteria we already know if it would negative or
not. In that case the parameter is not needed at all.

But maybe, in some special situation, someone can need to reverse the
setNegative() effect in the criteria. In this case the param is needed.

This are just random thoughts about this topic.

Best Regards,

Antonio Gallardo


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


Re: Persistence Broker 'NOT' Criteria

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi robert,

what do you think about a 'NOT'-flag in the criteria ?

Criteri crit = new Criteria();

crit.addEqualTo("field1","test1");
crit.addEqualTo("field2","test1");
crit.setNegative(true);

result:

select ... from ... where NOT (field1='test1' and field2='test2')


jakob

Robert Coup wrote:

> Hi all,
> 
> I find the PB Query interface nice to use, and we're wrapping it on the UI side
> of our application to allow users to do some simple querying. Then I ran into a
> small problem - there is no addNotCriteria! :)
> 
> Since you need AND, OR, and NOT to make any boolean expression it seems a bit
> strange that it isn't in there...
> 
> and while you can do:
>   A.a=1 and A.b!=1 and A.c!=1
> you can't 'not' a whole sub-criteria:
>   A.a=1 and NOT (A.b=1 or A.c=1)
> 
> Was there any particular reason that it was left out, or any easy work-around
> bearing in mind the query structure could be a lot more complex than my example?
> 
> OTOH, where would I look to add it? From my brief glance around Criteria I would
> need to add another Type, but the code to go from Criteria to SQL i didn't find...
> 
> Thanks,
> 
> Rob :)
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 


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