Undo generated properties on general persistenceExceptions#3647
Undo generated properties on general persistenceExceptions#3647rPraml wants to merge 3 commits intoebean-orm:masterfrom
Conversation
With ebean-orm#2372 we introduced a rollback mechanism when an optimisticLock happend, so that you can correct the issue and retry. This PR also handles the situation for other persistence exceptions like DuplicateKey
| /** | ||
| * Undos generated properties. | ||
| */ | ||
| default void onFailedUpdateUndoGeneratedProperties() { |
There was a problem hiding this comment.
checkme: Rename to "onExecuteUndo(ex)"?
Are there possible uses cases in CallableSql/OrmUpdate/SqlUpdate?
…eExceptions With ebean-orm#2372 we introduced a rollback mechanism when an optimisticLock happend, so that you can correct the issue and retry. This PR also handles the situation for other persistence exceptions like DuplicateKey fix test
We must handle batch updates differently. Here we have to roll back all statements in a batch. Also we must not roll back generated properties, if we did not modify them
|
Hmm, this is not as easy as I thought... I would first like to ask whether the following is a valid expectation:
The above is easily accessible for noBatch. I extended #2372 that insert/update/delete undoes exactly the properties, that were modified. ( The batch case is more complex: We might have several BatchedPstmts, maybe for different beans. If one of them will fail in the transaction, we have to undo all of them. So we might save 1000s of beans in one transaction and the I'm a bit unhappy about the solution, because it will not work reliable. There are @rbygrave How do you see this? Is my assumption already wrong? Or can we only guarantee this in noBatch mode? |
With #2372 we introduced a rollback mechanism when an optimisticLock happend.
This PR also handles the situation for other persistence exceptions like DuplicateKey in a similar way, so that you can correct the issue and retry save.
Please take a look, if this makes sense to you.