cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Huss <johnth...@gmail.com>
Subject Re: Fetching distinct related objects
Date Tue, 22 Sep 2015 15:55:24 GMT
Sorry, I misunderstood.  I assume you're actually including a qualifier or
where clause, not just fetching everything?

On Tue, Sep 22, 2015 at 10:39 AM Hugi Thordarson <hugi@karlmenn.is> wrote:

> Doesn't setDistinct always work with the entire row? I’m attempting to
> fetch just the distinct values of certain relationships. I haven’t found an
> API for that in Cayenne, that’s why I’m using EJBQL.
>
> Then again, I might be on the wrong track…
>
> Thanks,
> - hugi
>
>
>
> > On 22. sep. 2015, at 15:29, John Huss <johnthuss@gmail.com> wrote:
> >
> > selectQuery.setDistinct(true);
> >
> > On Tue, Sep 22, 2015 at 9:37 AM Hugi Thordarson <hugi@karlmenn.is>
> wrote:
> >
> >> Hi all,
> >>
> >> I’m trying to retrieve a list of distinct related objects. If I execute
> an
> >> EJBQL-query that looks like this…
> >>
> >> "select distinct receipt.shop from Receipt receipt”
> >>
> >> …where “shop” is a relationship on the “Receipt”-entity, I get an
> >> exception that looks like this:
> >>
> >> https://gist.github.com/hugith/c3f48c4576e6a55383b3
> >>
> >> Doing the same fetch without the distinct keyword works fine (returns a
> >> list of Shop objects). Also, performing a distinct fetch on attributes
> of
> >> “Shop” works fine, like so:
> >>
> >> "select distinct receipt.shop.name from Receipt receipt”
> >>
> >> Is this a bug or am I going around this the wrong way? How would you go
> >> about constructing a fetch for distinct related objects?
> >>
> >> Cheers,
> >> - hugi
> >>
> >> // Hugi Thordarson
> >> // http://www.loftfar.is/
> >> // s. 895-6688
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message