I have three tables: event, speaker, event_speaker
Events and speakers have an n:m relationship managed by the "event_speaker" table. I used the jOOQ maven codegen to generate files like "EventRecord" and "SpeakerRecord".
In my application I want to get all speakers for a particular event. So I need to join the "speaker" table with the "event_speaker" table to be able to limit the results by the event id:
return dsl.select(SPEAKER.asterisk())
.from(SPEAKER)
.leftJoin(EVENT_SPEAKER).on(SPEAKER.ID.eq(EVENT_SPEAKER.SPEAKER_ID))
.where(EVENT_SPEAKER.EVENT_ID.eq(eventId))
.fetch();
Now I'll get a Result<Record>
as the return value. But I would like to get a Result<SpeakerRecord>
as the return value. If I remove the join, I will get it (but of course the result set will contain all speakers, which I don't want).
How is it possible to get a SpeakerRecord
in place of the more general Record
object when I need a join?