Search code examples
jooq

JOOQ join two tables with same column names


I'm using running following JOOQ query:

dsl.select().from(table).join(joinTable).on(joinCondition).where(condition).fetchInto(entityClass);

Both table and joinTable have id as primary key name, but resulting fetch into entity class contains id of joinTable, and rest of columns of table. If I reorder tables, result is similar, I have ID from table and rest of columns from joinTable.


Solution

  • Metamodel is generated using jooq-codegen-maven plugin. Interesting, I found out that using:

    dsl.select(table.fields())...
    

    solves problem. I would expect that this behavior is by default, but it is not.