mat_boy
mat_boy

Reputation: 13666

jOOQ how to extract a value from a Field

I'm joining some tables from jOOQ and I'd like to use a RecordMapper to parse the result into my pojo AType.

final List<AType> typeList = dsl.select()
                .from(TABLEA)
                .join(TABLEB).on(TABLEA.ID.equal(TABLEB.ID))
                .fetch()
                .map((RecordMapper<Record, AType>) record -> {
                     //Extract field values from Record
                     return  new AType(....);
                });

As I explained in a comment, I would like to know how to convert a Field object from the Record into the contained value.

Upvotes: 8

Views: 9289

Answers (1)

Lukas Eder
Lukas Eder

Reputation: 220952

The method you're looking for is Record.getValue(Field) (or also Record.get(Field) from jOOQ 3.8 onwards):

.map((RecordMapper<Record, AType>) record -> {
     //Extract field values from Record
     return new AType(record.getValue(TABLEA.ID), ...);
});

Upvotes: 11

Related Questions