Hi Jakob,

I think an addNot(Criteria crit) would make more sense, be more flexible,
and be more in fitting with the rest of the QueryByCriteria API.

e.g.

Criteria main = new Criteria();
Criteria subCriteria = new Criteria();
subCriteria.addEqualTo("field1","test1");
subCriteria.addEqualTo("field2","test2");
main.addEqualTo("field3","test3");
main.addNot(subCriteria);

result:

select ... from ... where field3='test'3 AND NOT (field1='test1' and
field2='test2')

Just my tuppenceowrth. (1 tuppence == 2 EUR)

Cheers,

Charles.

> -----Original Message-----
> From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]
> Sent: 08 December 2003 21:30
> To: OJB Users List
> Subject: Re: Persistence Broker 'NOT' Criteria
> 
> 
> 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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


___________________________________________________________
HPD Software Ltd. - Helping Business Finance Business
Email terms and conditions: www.hpdsoftware.com/disclaimer 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to