Thanks Lukas, I have read the contents of issues/5961, but it seems has a lower priority to support. But I think it would be better to implements this, since it may be a common solution to resolve duplicate name problems in Jooq.
I cannot use column alias to implement this, since I need a dynamic query not a static one. I will try to write a custom RecordMapper to implement this. Thank you. Extjs On Monday, August 26, 2019 at 6:14:52 PM UTC+9, Lukas Eder wrote: > > For the record, this question has also been asked here: > https://stackoverflow.com/q/57654944/521799 > > On Monday, August 26, 2019 at 9:43:56 AM UTC+2, Lukas Eder wrote: >> >> 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] <javascript:>> 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] <javascript:>. >>> 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/2e99dc8b-d732-4aff-a357-8412e5c75b07%40googlegroups.com.
