Hi Sylvain,

I assume the collection contains all "or" values for a given column - in
your example, packageOwner.

You could do what you are trying to do like
Criteria mainCriteria = new Criteria();
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
        String owner = (String) iter.next();
        Criteria tmp = new Criteria();
        crit.addIsLike("packageOwner", owner);
        mainCriteria.addOrCriteria(tmp);
}
[.. do query ..]

However, it makes far more sense in this scenario to do an "in" query that
would map 
to "SELECT blah FROM atable WHERE packageOwner in ('me', 'you',
'someoneElse')

You can do that very simply in OJB :
Criteria mainCriteria = new Criteria();
mainCriteria.addIn("packageOwner",collection);

[.. do query ..]


Cheers,
Charles.

>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Sent: 31 March 2003 08:30
>To: [EMAIL PROTECTED]
>Subject: how to create dynamic criteria?
>
>
>Hello,
>
>I have this problem:
>
>I have a Collection that contains n String (I don't know the 
>number in advance).
>
>These n String are used to construct some criteria. Each 
>String is used for one criteria.
>I need OR statements between criteria, like:
>crit1 OR crit2 OR crit3 OR ... critn
>
>The criteria should look like: crit.like("packageOwner", owner);
>
>the code is:
>----code----
>Iterator iterator = collection.iterator();
>while (iterator.hasNext()) {
>String owner = (String) iter.next();
>//construct some criteria with OR statements between them
>
>???????
>
>}
>----code----
>
>How can I construct these criteria with OJB?
>Is anyone has an experience?
>
>
>Thanks in advance
>Sylvain
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


This email and any attachments are strictly confidential and are intended
solely for the addressee. If you are not the intended recipient you must
not disclose, forward, copy or take any action in reliance on this message
or its attachments. If you have received this email in error please notify
the sender as soon as possible and delete it from your computer systems.
Any views or opinions presented are solely those of the author and do not
necessarily reflect those of HPD Software Limited or its affiliates.

 At present the integrity of email across the internet cannot be guaranteed
and messages sent via this medium are potentially at risk.  All liability
is excluded to the extent permitted by law for any claims arising as a re-
sult of the use of this medium to transmit information by or to 
HPD Software Limited or its affiliates.



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

Reply via email to