Here's another attempt at using fetchGroups, jOOQ says "JooqLogger.java:370 
- Ambiguous match found for id. Both "child"."id" and "parent"."id" match":

Map<ProductionEntityRecord, List<ProductionEntityRecord>> m =
        this.create.select()
                   .from(child)
                   .leftJoin(parent)
                   .on(child.PARENT_PRODUCTION_ENTITY_ID.eq(parent.ID))
                   .where(child.EXTERNAL_ID.eq(externalId))
                   .fetchGroups(c -> c.into(PRODUCTION_ENTITY),
                                p -> p.into(PRODUCTION_ENTITY));


This also has the disadvantage of not letting me "fetchOne" and having to 
deal with the map key iterator in an awkward way.

On Thursday, February 15, 2018 at 10:03:40 AM UTC-8, Jason Bennett wrote:
>
> Here's where I've ended up:
>
> com.ep.core.project.jooq.tables.ProductionEntity parent = 
> PRODUCTION_ENTITY.as("parent");
> com.ep.core.project.jooq.tables.ProductionEntity child = 
> PRODUCTION_ENTITY.as("child");
>
> Record7<Long, UUID, String, String, OffsetDateTime, OffsetDateTime, UUID> r =
>         this.create.select(child.ID,
>                            child.EXTERNAL_ID,
>                            child.NAME,
>                            child.SLUG,
>                            child.CREATED,
>                            child.UPDATED,
>                            parent.EXTERNAL_ID)
>                    .from(child)
>                    .leftJoin(parent)
>                    .on(child.PARENT_PRODUCTION_ENTITY_ID.eq(parent.ID))
>                    .where(child.NAME.eq(name))
>                    .fetchOne();
>
>
> What I would love is to somehow get a parent object and a separate UUID 
> out of that query, without having to resort to that ugly Result object.
>
>
>
>
> On Thursday, February 15, 2018 at 12:20:49 AM UTC-8, Lukas Eder wrote:
>>
>> This should work if either:
>>
>> 1. The columns are fully qualified
>> 2. The columns are renamed
>>
>> How di you run your query and how did you call fetchGroups()?
>>
>> 2018-02-14 21:14 GMT+01:00 <[email protected]>:
>>
>>> Normally when I do a join query, I just use fetchGroups() and fetch the 
>>> records into their respective types, then iterate across entryKey() - no 
>>> problem.
>>>
>>> When I do this with a recursive join, however, jOOQ appears to get 
>>> confused, and cannot distinguish between the child record and the parent 
>>> record (I assume since the column names are the same). What's the best way 
>>> to fetch this?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "jOOQ User Group" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to