Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jOOQ how to extract a value from a Field

Tags:

java

sql

jooq

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.

like image 809
mat_boy Avatar asked Apr 10 '16 20:04

mat_boy


1 Answers

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), ...);
});
like image 113
Lukas Eder Avatar answered Oct 05 '22 06:10

Lukas Eder