I've just started using LLBLGEN, and I'm not very knowledgeable on the various hookpoints available for the various generated code types, and their various capabilities. I am using the
Adaptor code generation templates.
So...
Concurrency Scheme
My (Oracle) database supports concurrency via a '_change control count_' field (term I just made up
) on each table, and update triggers on each table that check whether, for every UPDATE, the update increments the CCC field.
So, to recap, in order for an update to succeed, the client has to make sure they increment the CCC field.
If any update fails to increment this CCC field from the existing database value to a value one higher, then the update fails, since it looks like the update is a change to an out-of-date version of the record, or it's being attempted by somebody who doesnt know about what they should be doing to the CCC field.
It's a bit like an implementation of SQLServer's timestamp field with integrated concurrency checking added.
What I Want to Achieve
What I would like to achieve is for my DAL to deal with the CCC field, so that the programmer (me!) doesnt have to remember to manually increment it field whenever he saves changes to an entity.
As I understand it, it's possible to inject WHERE clauses into UPDATES via predicate factory, but in this case, I need to inject a field update ("CCC=:ccc_plus1").
Does anyone have any ideas as to how to achieve this goal?
Will it need a modification of the templates?
Can I subclass DataAccessAdaptor to insert this functionality?
etc...
edit: I found a place in DataAccessAdaptor base where, if I had the chance, it looks like I could update the CCC field, and let the existing code take its course. No idea if that approach would actually work. (before // retrieve persistence information In SaveEntity method)