I have the following query in jOOQ:
factory()
.select()
.from(PERSON)
.join(ENDUSER).on(ENDUSER.PERSON_FK.equal(PERSON.ID))
.where(ENDUSER.ID.equal(userId))
.fetchOne();
This query returns to me a Record with all columns from PERSON and ENDUSER, but I only want the columns from PERSON (that's why I put .from(PERSON)
and not .from(PERSON, ENDUSER)
).
I know it doesn't matter that much but I don't want unnecessary fields to be returned.
Lukas's answer was exactly what I was looking for. You can also use the into()
method to get a strongly typed response object back for only the table you care about (instead of the generic Record
type):
PersonRecord record = factory()
.select()
.from(PERSON)
.join(ENDUSER).on(ENDUSER.PERSON_FK.equal(PERSON.ID))
.where(ENDUSER.ID.equal(userId))
.fetchOne()
.into(PERSON);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With