revisions are created only when a transaction is commited. That's beacuse flushing may occur at unpredicatble times, depending on your configuration, so when you execute update(), or a query. I think creating revisions on transaction commits is what you really want :)
I was looking at the implementation and I believe the WorkUnits only get executed in case of Transaction commit, which means flushing will be ensured even if we allow versions creation at each saveandUpdate but final creation of version is only on transaction commit ?
My use case is to create 7 versions of an Object and if any intermediate version creation fails then don't create any version. This could have been easy if I follow the following algo:
transaction.start(); object obj.... .. .. sessions.saveandUpdate(obj)... ... ... do this seven times and see if anything fails ....if no failure then commit the transaction ... ... transaction.commit();
Any ideas ?
you're right, the work units get executed only when the transaction as commited. Only then I can be sure what is the data content of the revision.
Why would anything fail when creating versions?
If anything does, then the whole transaciton will be rolled back, and no changes will be made.