Hi all,
I have a question regarding queries on m:n relations. Suppose I have two
classes which are associated in OJB through a m:n relation, objects of type
'A' and 'B'. 'A' has a property called 'bees' returning all objects of type
'B', 'B' has a property called 'as' which returns all 'A' objects.
This all works nicely in OJB, storing, updating, deleting. But now I want to
query. I have an object of type 'B' and I want to know which objects of type
'A' are associated to it. In other words, I'd like a query which results in
a collection of 'A' objects for which 'B' is in the collection 'A.bees'.
How would this work?
I cannot simply go and create a query like:
Criteria c = new Criteria();
c.addEqualTo("bees", B);
Query q = new QueryByCriteria(B.class, c, false);
broker.getCollectionByQuery(q);
because bees is a collection. Will Criteria.addIn work? And if this doesn't,
what will?
I have looked at QueryByMtoNCriteria but the documentation of this was
rather unclear.
Also, I might be able to use Criteria.addExists, but I need to refer to a
field from the main query in the subquery, otherwise my subQuery isn't of
much use.
Help!
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>