Thank you very much for your message. Unfortunately, this is not yet supported in jOOQ. We have a feature request to improve this: https://github.com/jOOQ/jOOQ/issues/5961
As a workaround, you could write your own RecordMapper (possibly extending upon DefaultRecordMapper) and hook it into your Configuration using a RecordMapperProvider: https://www.jooq.org/doc/latest/manual/sql-execution/fetching/pojos-with-recordmapper-provider/ Alternatively, instead of using JPA annotations (I'm not sure if that is actually idiomatic JPA usage), you could alias your projected columns to TABLE_A.NAME.as("name_a") or TABLE_A.NAME.as("nameA") to get the wanted behaviour. I hope this helps Lukas On Fri, Aug 23, 2019 at 5:07 PM <[email protected]> wrote: > Hi, everyone > > I have two tables: TABLE_A and TABLE_B, they have some columns with the > same names. > > TABLE_A (ID, NAME, ADDRESS) > TABLE_B (ID, NAME) > > I want to retrieve all columns from both tables by join: > > > > > > *List<MyDto> results = query.select() > .from(TABLE_A) > .join(TABLE_B) .on(TABLE_A.ID.equal(TABLE_B.ID > <http://TABLE_B.ID>)) .fetchInto(MyDto.class);* > > And I use the @Column annotation to specify which column comes from which > table, like this: > > > > > > > > > > > > > > > > > > > > > *import javax.persistence.Column;public class MyDto { @Column(table = > "TABLE_A", name = "ID") private String idA; @Column(table = > "TABLE_A", name = "NAME") private String nameA; @Column(table = > "TABLE_A", name = "ADDRESS") private String addressA; @Column(table = > "TABLE_B", name = "ID") private String idB; @Column(table = > "TABLE_B", name = "NAME") private String nameB;}* > > or this: > > <code> > import javax.persistence.Column; > > public class MyDto { > > @Column(name = "*TABLE_A*.ID") > private String idA; > > @Column(name = "*TABLE_A*.NAME") > private String nameA; > > @Column(name = "*TABLE_A*.ADDRESS") > private String addressA; > > @Column(name = "*TABLE_B*.ID") > private String idB; > > @Column(name = "*TABLE_B*.NAME") > private String nameB; > > } > </code> > > But both cannot work as expected, does Jooq support this feature? > If not, how to implement this? > > Thanks, > Extjs > > -- > 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]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jooq-user/e8877340-f107-4a95-b28e-040591e46078%40googlegroups.com > <https://groups.google.com/d/msgid/jooq-user/e8877340-f107-4a95-b28e-040591e46078%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/CAB4ELO5ES45i--TF9JF-vKw2bC_FcCP-xTH9QddeoDmVKhuGJg%40mail.gmail.com.
