Hello,
This question keeps popping up on the list and elsewhere, and I always have the same counter question. If you need optimistic locking, then why not just use the record all the way to help you keep track of the internal flags? What are you gaining from using the POJO intermediary? Sure, you can prevent the dependency on jOOQ where you might prefer not to have such a dependency, i.e. the UI.
But since you want optimistic locking to apply, you have an implicit dependency anyway, so why not just use the Record?
If using the POJO is imperative, then yes, your code is one reasonable way to transfer information back to the record.
Regarding your question about adding more logic to your POJOs, you can extend the JavaGenerator to generate "custom code sections" for you, in any generated artefact:
You can also completely override the generation of POJOs in JavaGenerator and generate whatever you need inside of them.
Hope this helps,
Lukas