I have a table Foo defined as

create table FOO {
  name varchar(123),
  from varchar(123) default null
}

I am using JOOQ 3.16 and already have following code 
`db.insertInto(Foo).set(Foo.name, "xxx").execute()` everywhere. Now I want 
to find a way to re-write that query to effectively be 
`db.insertInto(Foo).set(Foo.name).set(Foo.from, "XYZ")` where "XYZ" is a 
dynamically computed value. But I don't want to make that actual change 
into 100s of places. Instead I want to do it once and centrally in JOOQ 
level to re-write the insert query dynamically. 

Basically below is what I want to achieve

- Intercept the query before it get executed
- if the query is an insert query, for FOO table, set column "FOO.From" to 
be something meaningful
- execute that re-written query to insert the entry with "from" column 
properly populated. 

I am assessing the option to have a new "ExecuteListener" where the 
"ExecuteContext" is given. I can get a "Query" (or batched queries) from 
it, inspect if it is insert statement, and call `addValue`  to add the 
right value for "from". The only blocker is, there doesn't seem to be a 
good way for me to tell what table it is, as I only want to add value for 
table "FOO". "Query" does has "table" property which is not exposed 
publicly unfortunately. 

Would appreciate some help about the best way to achieve my goal. Thanks. 

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/66986af7-18cc-4cfc-a3db-f4b90d12e0dfn%40googlegroups.com.

Reply via email to