Suppose I have a custom RecordMapper due to whatever reaons:
public class UserGroupMapper implements RecordMapper<Record, UserGroup> {
@Override
public UserGroup map(Record rec) {
UserGroup grp = new UserGroup(rec.getValue(USER_GROUP.ID),
rec.getValue(USER_GROUP.NAME),
rec.getValue(USER_GROUP.DESCRIPTION)
javaParseTags(USER_GROUP.TAGS)
);
}
In JOOQ, I could use it like so:
ctx.select()
.from(USER_GROUP)
.fetch(new UserGroupMapper());
However, if I want to select multiple things (like data from a left join), it would be convenient to not use the RecordMapper in the last step (fetch step) but already during the select step as I have seen as an example here with POJOs, not RecordMappers: ctx.select(row(A, B, C).mapping(MyPojo::new), otherFieldsLikeMultiSet)
My question: Is there something like this syntax available for normal RecordMappers as well? The mapping function expects a FunctionN<AllMyFields..., ?> and not something like Function<Record, ?> as the RecordMapper implements.
So some code somewhat like this:
UserGroupMapper mapper = new UserGroupMapper(); //Implements RecordMapper
var res = ctx.select(
row(
USER_GROUP.ID,
USER_GROUP.NAME,
USER_GROUP.DESCRIPTION,
USER_GROUP.TAGS
).mapToMyPojo(mapper), // this function doesn't exist. How to utilize my mapper here?
USER_GROUP.JSONLOAD
)
.from(USER_GROUP)
.fetch();
Now, I'd like to have a Result<Record2<UserGroup,String>>. So instead of using the recordmapper "in the end" at fetch phase, I'd like to apply the RecordMapper earlier. I know it's possible when providing a FunctionN to the row object mapping, but my RecordMapper sadly isn't a FunctionN :)