Humaid Kidwai
Humaid Kidwai

Reputation: 99

How to map left joined tables to generated POJO classes accurately?

Table A:

Table B:

Here is the query:

Result<Record> result = ctx.select().from(A).leftJoin(B).onKey().where(condition).fetch()

If I select all the fields, join these tables, fetch the result set into Result<Record> then try to fetch the 'name' column of respective tables (record.get(A.name)), it leads to incorrect values. The value of the first occurrence of 'name' is always returned.

If I try to map the records, first into ARecord.class and then into BRecord.class, the 'name' value is still incorrect.

If I do it using the generated POJO classes, it is still incorrect, except the last occurrence overwrites the value of 'name' instead of first occurrence.

How am I then supposed to join multiple tables and fetch/map the records into my custom POJO classes then? As I am dynamically constructing my SQL queries, I can not use multiset or use maps to return the records into. I need to be able to first get Result<Record> and then map it.

Upvotes: 0

Views: 46

Answers (0)

Related Questions