How to get join table results in jOOQ?

I have one small special case in my database where I need to get data from two different tables, which are one-to-one, in order to get a useful result. The output looks something like this:

SELECT 
  time_period.from_day, time_period.to_day, store_time_period.valid_for_days 
FROM time_period, store_time_period 
WHERE 
  -- .. condition

Of course I use JOINin my actual code - this is just an example. My question is how and how can I write the received data in jOOQ in POJO. I'm not sure if there is a way to let jOOQ generate this POJO for me, but if I need to write it myself, I assume that I will need something like an adapter, as well org.jooq.Converteras a converter for data types.

I see that there is a possibility RecordMapperProvider, but this seems to handle only one, already known table.

So what is the best way to accomplish something like this with jOOQ?

+4
source share
1 answer

You can get a (non-generated) POJO without the need for an adapter or converter. See this page from the documentation jOOQfor an example.

jOOQwill map columns from the query to POJO fields based on their names. Names do not have to be exact matches with column names; DefaultRecordMapperdocs are a few examples that show how underscores and capitalization are ignored.

POJO . , POJO , . , JPA, jOOQ, :

@Column(name = "TITLE")
public String myTitle;

( , : HashMap.)

+1

Source: https://habr.com/ru/post/1623424/


All Articles