Hello,

I have a CRUD application which writes data from different sources to 
PostgreSQL (REST API, kafka...) using jOOQ, and I'm trying to find a way 
how to implement logic like: "whenever attribute X of table Y is updated, 
do Z" (without putting lots of if's everywhere attribute X might be 
changed).

If I was using JPA, I'd use something like @PreUpdate entity listener and 
I'm wondering if there's a way how to do something similar in jOOQ. The app 
is not doing any complex updates with subselects, it's all simple "INSERT 
INTO xxx VALUES yyy" or "UPDATE x SET y WHERE z" queries.

I've found Execute Listeners 
<https://www.jooq.org/doc/latest/manual/sql-execution/execute-listeners/> which 
seems like the thing I'd want - I can get each query before it's executed, 
but it doesn't seem like I can do much with the query itself - ideally I'd 
want to get affected table, updated columns and maybe insert condition. 
Rendering the query into string and then parsing that seems like a bad 
solution.

I've also found VisitListener 
<https://www.jooq.org/javadoc/latest/org.jooq/org/jooq/VisitListener.html> 
which 
seems useful (although somewhat difficult to implement) - I can parse the 
query programmatically. But it seems like it's called whenever the sql is 
rendered, so for example if I turn on logging, the listener is called 
multuple times for each query.

Is there a way how to do something like this in jOOQ? 

-- 
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/d0ef1e88-e803-413b-b3e5-5ceab0d8be9bn%40googlegroups.com.

Reply via email to