Actually "distinct" is added to SelectQuery automatically by Cayenne
whenever there is a match on to-many relationship. So it should just
work if you are running this against the db.
In-memory matching via Expression.filter won't work on the other
hand. As Cayenne itself is not attempting to be an in-memory RDBMS
there are some limitations.
On Nov 3, 2005, at 3:56 AM, Jeff de Vries wrote:
> RTFM ... while re-reading the expression stuff, I saw that I can
> use the *Array stuff in the path expression, so I can do things like:
> Expression e = ExpressionFactory.matchExp("childArray.property",new
> (assuming my root object is parent).
> How can I get each parent only once, instead for each matching
> child? (I think this is UNIQUE in SQL?)
> Jeff de Vries
> Jeff de Vries wrote:
>> Assume I have the following tables:
>> create table parent (
>> id int primary key,
>> ... stuff
>> create table child (
>> parent_id int foreign key references parent(id),
>> ... stuff
>> I need to find all the *parent* objects such that they have at
>> least one *child* object that meets some given set of conditions.
>> I can live with if a parent that has more than one child with the
>> condition gets listed multiple times, but ideally each parent
>> would only show up once.
>> Sorry if this is some really basic SQL thing ...
>> Jeff de Vries
This archive was generated by hypermail 2.0.0 : Thu Nov 03 2005 - 02:22:32 EST