Simple mapping on jooq with join

I am trying to do a simple mapping of a nested class, but I was unable to understand from the documentation if i should use row or field to map the inner class.

            .select(
                Tables.Outer.NAME,
                Tables.Outer.Inner_FK,
                row(
                    select(Tables.Inner.NAME)
                        .from(Tables.Inner)
                        .where(Tables.Inner.ID.eq(Tables.Outer.Inner_FK))
                ).mapping { Inner::class.java }
            )
            .from(Tables.Outer)
            .where(Tables.Outer.ID.eq(id))
            .fetchOne()
            ?.map { r -> r.into(Outer::class.java) }

It is probably something silly I am not seeing.

Thanks !

I am getting Caused by: java.sql.SQLException: Error while reading field: row ((
select “public”.”Outer”.”name”
from “public”.”inner”
where “public”.”inner”.”id” = “public”.”Outer”.”inner_fk”

Leave a Comment