if it can help someone, I have found a solution with recordListener. 

Example : 

@Override
public void updateStart(RecordContext ctx) {
Row rows = ctx.record().fieldsRow();
List<Field<?>> fields = Arrays.asList(rows.fields());
for (Field f : fields) {
if (ctx.record().changed(f)) {
LOG.info("AUDIT TRAIL - Changed into <" + ((TableField) 
f).getTable().getName() + "."+ f.getName() + "> original value <"
+ ctx.record().original(f) + "> new value <"
+ ctx.record().getValue(f).toString() + ">");
//can insert into a single audit table...or something more sophisticated 
like hibernate envers...
}
}
super.updateEnd(ctx);
}



Le vendredi 26 septembre 2014 07:32:16 UTC+2, Lukas Eder a écrit :
>
> You have, of course, several options to implement audit trails.
>
> If you want to stay 100% sure to catch all updates, database triggers are 
> your best way to go, here.
>
> Otherwise, from a jOOQ perspective, RecordListener is the easiest to help 
> you implement audit trails, although it will limit your application design 
> by enforcing all updates to go via UpdatableRecord.store() and similar.
>
> While you could delve into a harder-to-implement, yet possibly more 
> reliable solution based on VisitListeners, there will always be cases 
> involving bulk DML that you won't be able to catch, and that can be covered 
> using triggers, only:
>
> - MERGE statement
> - INSERT .. SELECT statements
> - Multi-row UPDATE statements
>
> *If others want to share their actual experience, I think that would be 
> very interesting for the group.*
>
> Hope this helps,
> Lukas
>
>
> 2014-09-25 18:25 GMT+02:00 <[email protected] <javascript:>>:
>
>> Hummm, It seems to be better with RecordListener which permit to have the 
>> complete record and the modification.
>>
>> Le jeudi 25 septembre 2014 17:29:03 UTC+2, [email protected] a écrit :
>>
>>> Hello,
>>>
>>> Do you know what is the best way for doing Audit trail with Jooq ? I 
>>> think ExecuteListener can be good solution, but if someone has already 
>>> implemented this, It could help me a lot.
>>>
>>> Is there a way to catch fields that have been updated after a update 
>>> statement ?
>>>
>>> Thanks for your helps.
>>>
>>> Alex
>>>
>>>
>>>  -- 
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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/d/optout.

Reply via email to