Ok. Recursive saves are great, however very complex behind the scenes. As you've probably recognized in the past few weeks, some issues have been plagueing the recursive save logic, however it seems to be working fine now.
Below are the 2 issues which are still in the recursive save logic. One is a little thing to fix, the other one is a possible nasty one as a fix will probably break not so well constructed applications.
1) Saving an entity collection recursively will not report the correct amount of entities saved. This is not that hard to fix
2) When a save somewhere deep in the hierarchy fails, during a recursive save, the complete transaction isn't aborted, the save just failed.
Every entity saved in a transaction is internally 'backupped', that is: all fields are backupped, and if a transaction fails, the original fields are restored with the backup. This is done to avoid refetches of data being kept in memory after the transaction is terminated and rolled back.
This means that a transaction in fact is an atomic save: if an error occurs, nothing is changed in the database nor is any refetching of already saved data messing up the data internally.
And now for the question
.
If a save of an entity reports 'false', which means 0 rows were affected by the save (thus the entity in the database was removed or a concurrencypredicate limited the scope of the update) should this be a terminating factor for the complete transaction? In other words: IF an entity save action fails, should it throw an exception? (Which will roll back the transaction).
My own opinion: yes, a failed save should throw an exception during a recursive save. (not during a regular save). This is based on the analogy that an error also throws an exception terminating the complete transaction.
Why is this an important thing to discuss? Well, if you've constructed your application in a way that you use recursive saves just to save some entities, thus not using concurrency predicates, you probably will not catch the exception. This can make working applications become unusable.
This doesn't occur a lot though. If you look at it like: you've altered an entity. You want to save it. In a situation where you didn't use a concurrency predicate factory, this only fails when the entity is deleted by another thread. Is it then good that this update's failure goes unnoticed? No, I don't think so. That's why I think the exception is good.
However, as it might affect you all, my question to you is: should this exception be added or not?
TIA