A little mistake in the Java statement. It should be
if (productGroup.allArticlesInGroup.contains(a1) &&
productGroup.allArticlesInGroup.contains(a2))
Where a1.articleName = "Article 1" and a2.articleName = "Article 2". Of
course we've to overwrite equals to compare articles by their name ...
Whatever, I hope it's clear now.


-----Urspr�ngliche Nachricht-----
Von: Gregor Heinze [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 18. M�rz 2003 16:41
An: OJB Users List
Betreff: AW: Query against Collection with more than one addEqualTo
statement.


Thanks for your fast reply.

Maybe I was unclear? It's not the articles I'm about it's the product groups
containing the articles. So I'm trying to say: "Give me all product groups
that have an article where article.name = 'Article 1' AND an article where
article.name = 'Article 2'".
Or to say it in Java, a match would be
if (productGroup.allArticlesInGroup.contains("Article 1") &&
productGroup.allArticlesInGroup.contains("Article 2"))



-----Urspr�ngliche Nachricht-----
Von: Michael Duffy [mailto:[EMAIL PROTECTED]
Gesendet: Dienstag, 18. M�rz 2003 16:31
An: OJB Users List
Betreff: Re: Query against Collection with more than one addEqualTo
statement.



The empty collection result makes perfect sense if the
default behavior is to AND criteria together.  None of
your articles have both names set (exclusion at work),
so nothing comes back.

Aren't you trying to say "Give me all the articles
where name = 'Article 1' OR name = 'Article 2'"?

If I understand correctly, I think you want to use
either the addOrCriteria or addIn methods. - MOD

--- Gregor Heinze <[EMAIL PROTECTED]> wrote:
> For the sake of simplicity, I refer to the class
> model from the tutorial
> "Advanced Object Relational Mapping techniques" to
> explain my problem. It
> seems to be quite simple but I wasn't able to figure
> it out correctly.
> All I want to do is to get all ProductGroup's which
> have an Article with the
> articleName "Article 1" _and_ an Article with the
> articleName "Article 2" in
> its allArticlesInGroup Vector.
> Using the PersistenceBroker API I wrote the
> following:
>
> Criteria crit = new Criteria();
> crit.addEqualTo("allArticlesInGroup.articleName",
> "Article 1");
> crit.addEqualTo("allArticlesInGroup.articleName",
> "Article 2");
> Query q = QueryFactory.newQuery(ProductGroup.class,
> crit);
>
> Unfortunately this approach does not work and I
> always get an empty result
> collection. Using only one addEqualTo statement
> works as expected but using
> two of them won't.
> Anyone has an idea how to do this? Any help is
> appreciated!
>
> Thanks in advanced,
>  Gregor
>


---------------------------------------------------------------------
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]

Reply via email to