Hi Lukas,
thanks for your response.
I already use your approach but with pojos and call it ...
// composition of jooq pojos
public class VerwaltungseinheitFullDto extends Verwaltungseinheit {
private Objekt objekt;
private Wirtschaftseinheit wirtschaftseinheit;
private Quartier quartier;
private Stadtteil stadtteil;
}
The problem is here how to efficiently map the database result set into that composition class without manually handle every field/attribute ?
Sometimes I use org.modelmapper for that
ModelMapper modelMapper = new ModelMapper();
modelMapper.getConfiguration().addValueReader(new RecordValueReader());
modelMapper.getConfiguration().setSourceNameTokenizer(NameTokenizers.UNDERSCORE);
I put the value of the composition dto attribute name plus the underscore as prefix for every fieldvar objektFields = Arrays.asList(VERWALTUNGSEINHEIT.objekt().fields()).stream().map(field -> field.as("objekt_" + field.getName())).toList();
and let the modelmapper do his job
var result = modelMapper.map(dbResult, VerwaltungseinheitFullDto.class);
But its quite slow and often I prefer the updateable records in order to store() the record directly back ....
So I didn't found a way to map such DTO like yours. RecordMapper, RecordHandler or something like this seems not appropriate at least in this way:
.fetch(new RecordHandler<KalkulationPositionRecord, CompositionDto>() {
@Override
public CompositionDto map(KalkulationPositionRecord position) {
CompositionDto result = new CompositionDto();
result.setDbRecord(position);
return result;
}
});
But I'm quite sure, you have a way to map that without handle every field manually... :-)
kind regards
Dominik