I have the exact same setup as you in a project with a H2 embedded database.

The situation with these triggers gets more complicated when you start 
considering transactions.

What we've done is implement a SQL parser, which parses the SQL statments 
in the JOOQ execute listener.

In short it does something like this:
If an insert:. It queries the data after inserted and puts it into a JOOQ 
record
If an update: It gets the where clause & then queries the database, getting 
the results and putting into JOOQ records.
If an delete: Before executing, it queries using the where clause and gets 
the results, and puts into JOOQ records.

Then it fires an event before and after the transaction is committed 
containing the records inserted, updated (before and after the update) and 
deleted. The system can listen to these events and react accordingly.

We use this mechanism for writing audit data, refreshing the UI, performing 
some more advanced validation, and triggering other tasks in the system.

It seems to be working well. The limitation is that we are restricted in 
the type of statements we can execute, because the parser is not very 
smart. But generally we are only running very simple update, delete and 
insert statements, so it isn't a big limitation for us.

I guess if you hook it into the H2 trigger system you could skip the query 
parser and handle any kind of query. But I wanted to keep it database 
neutral.

Ryan


On Monday, 11 March 2013 22:06:25 UTC+8, Dennis Fischer wrote:
>
> Hello,
>
> I've taken a look at jooq now and it looks like what I need.
> However - my application has a UI and needs to get notified about database 
> changes: insert, update and delete queries.
> I didn't find anything documented to this  - the only listener I've found 
> was the so called ExcutionListener - which seems not to be what I'm looking 
> for.
> Is this "feature" even supported directly in jooq?
>
> Otherwise - I'll probably extend the generated DAOs and add my custom 
> "Event-Callbacks" in there. The big downside which comes to my mind:
> I can't react on plain SQL queries and I can't react on delete by ID 
> calls. Additionally I'd have to add this event features to all DAOs which 
> would result in redundant code.
>
> Anything I'm overlooking?
>
> Regards,
> Dennis Fischer
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to