I have an app in the process of switching from jooq to jdbc, I created a table using jdbc but I need to edit some jooq queries to join it in, problem is that the auto generated jooq tables class does not recognize it, so is there a way to reference the table by string name?
Here is some sample code:
private final Business BUSINESS = Tables.BUSINESS; // table that jooq auto generated in jar file
....
Map<BusinessRecord, List<BusinessAddressRecord>> resultMap = dslContext
.select()
.from(BUSINESS.leftOuterJoin(BUSINESS_ADDRESS).on(BUSINESS.ID.eq(BUSINESS_ADDRESS.BUSINESS_ID)))
.where(BUSINESS.ID.equal(id))
.and(BUSINESS_ADDRESS.DEACTIVATED_AT.isNull())
.fetchGroups(
a -> a.into(BUSINESS),
b -> b.into(BUSINESS_ADDRESS)
);
How would I join a 'connection' table here? There is no Tables.CONNECTION since it was created a different way.
There are a lot of queries so we were hoping to make the switch gradually as needed.
UPDATE: I tried adding the following, and the query runs, but the field I'm trying to get is always null, I'm guessing because the BusinessRecord table does not have the same fields as the DTO, so how can this be resolved?
Map<BusinessRecord, List<BusinessAddressRecord>> resultMap = dslContext
.select()
.from(BUSINESS)
.leftOuterJoin(BUSINESS_ADDRESS)
.on(BUSINESS.ID.eq(BUSINESS_ADDRESS.BUSINESS_ID))
.join("connection")
.on("CAST(connection.business_id as bigint) = business.id")
.where(BUSINESS.ID.equal(id))
.and(BUSINESS_ADDRESS.DEACTIVATED_AT.isNull())
.fetchGroups(
a -> a.into(BUSINESS),
b -> b.into(BUSINESS_ADDRESS)
);