Hi Alf,

thanks for your message. 
I didn't realise that there was also this option. thanks for the hint, it 
makes implementation much easier and now works without reflection:

private void setModifiedBy(RecordContext ctx) {
   Field<String> modifiedByField = ctx.recordType().field("modified_by", 
String.class);
   if (modifiedByField == null) {
     log.warn("missing field 'modified_by'");
   } else if (StringUtils.isNotBlank(modifiedByField.get(ctx.record()))) {
     // field already set
   } else {
     ctx.record().set(modifiedByField, UsernameResolver.resolveUsername());
   }
}

And regarding the hint from Lukas and the audit capabilities of JOOQ:
i use the variant with the trigger that Vlad suggested in 
https://vladmihalcea.com/postgresql-audit-logging-triggers/

it has some advantages
1) only one stored prcedure
2) simple extension for new tables by defining another trigger that uses 
this SP
3) possibility to display detailed changelogs and modified_fields

But for the optimistick locking, I rely on JOOQ :-)

Kind regards
Dominik

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/d2ae7d7c-a781-4cb9-b904-d49d8ff99c6dn%40googlegroups.com.

Reply via email to