Search code examples
jooq

JOOQ MYSQL QUERY


select question.*, 
       question_option.id 
from question 
left join question_option on question_option.question_id = question.id;

how do i write question.* in jooq instead of specifying all the entity vaiables


Solution

  • You can use field() or asterisk() methods from the JOOQ generated objects which are extended from TableImpl.

    For example, if you just want to query the fields of a record:

    dsl.select(QUESTION.fields()).from...

    If you need fields from the join too:

    dsl.select(QUESTION.asterisk(), QUESTION_OPTION.ID).from...