>> Maybe, there is a way to implement this at the client side, using >> jooq-codegen's generated interfaces (which are implemented by the >> records)? Although those interfaces wouldn't be able to capture all >> possible events. > > I'm not quite sure what you mean here? Do you mean having a setting in the > jooq.xml which says "generate ValueChangeEvents" or something along those > lines?
No, but you could generate interfaces and implement those interfaces using java.lang.reflect.Proxy, hiding the actual record behind such a proxy. Within the proxy, parts of this listener API can be implemented, maybe. But it would probably be a clumsy solution, compared to actual listener support by jOOQ's core > The idea sounds good. I would love this kind of functionality. Even to > implement say an audit trail. But as you have mentioned in the past it is > hard to capture these events, for instance for a merge statement it is > unknown which records would be updated / inserted and also in more > complicated updates. It would be fine for using the UpdatableRecord.store() > because it only works on a single record at at time. Yes, it is very hard to actually foresee what the database does. It is probably even a bad idea to rely on anything, as the database can implement a trigger that prevents an insert from being executed (and executes an update instead). jOOQ would have no way to foresee that. > I wonder if you could make an interface that plugs into different databases > capabilities to provide this functionality. For instance it may need to > create a database trigger which somehow communicates back to JOOQ. I haven't > used enough databases to know if this is even generally possible. I guess at > the least it would kill performance. I guess that would be very unreliable... > I don't think a global event would be suitable for what I am looking for. > For many other cases, yes, but in this case it would complicate things (eg. > I would have to remember to remove listeners from UI fields when they are > disposed, where usually the record would be disposed at the same time as the > UI, or beforehand) Yes. Global event handlers are useful for other use-cases than yours. Cheers Lukas
