All in favor of removing autocommit, please upvote this ide, posted by a very experienced and well-respected Mendix Expert https://forum.mendix.com/link/ideas/650https://forum.mendix.com/link/ideas/650.
Yes, the idea is planned, but it has been for over 18 months now.
Hi Pieter,
I’ve also encountered some unexpected behaviour with autocommit. Technically, if you commit an object it is no longer autocommited and should also not be deleted by the autocommit behaviour. But I’ve also encountered cases where this did not seem to work like that. However I could never fully trace the wrong behaviour and in the end it was only fixed by avoiding the autocommit.
My thinking on this is: whenever you get some autocommit message consider this a bug and don’t expect to get any well defined behaviour.
regards, Fabian
I have had multiple discussions on this subject and I will share the latest response from Andrej Koelewijn on this subject:
Maybe an example will make this clear: suppose you have a form where users can create orders with order lines. User starts by filling out partial order (not committted), then creates a new order line and saves/commits this to the database.
At this point the order does not yet exist in the database. But mendix cant save the orderline without an order in the database, as it needs to create the association info in the db. This is solved by temporarily auto-commiting the partial (unfinished) order. This creates a temporary order in the database, but one which does not necessarily comply with all the validations (as it was never officially committed).
Now, if at this point the user changes his mind, and abandons the order, the order has never been officially committed by the user (just the line). Mendix interprets this as an indication that the user doesn't want the order with lines saved to the database and will remove the partial (autocommitted) order from the database at the end of the user session.
To avoid this, the developer should either 1) create a microflow in the order line save button which officially commits both the orderline and the order (and make sure both validate), or 2) not save the order line, but save the order + lines in one go when the complete order has been entered.
So the key to understanding this behavior is this: the reason auto-committed objects are deleted is that they just consist of partial data which has never been validated. If we leave them in the database, you will end up with incorrect data.
So indeed the delete behaviour does indeed remove committed objects. My opinion is that removing the object also leads to incorrect data in a lot of the time. A sollution might be to add another checkbox to the commit acction to also commit any changed referenced object at the same time. That would solve any modeler mistake because you forgot to save some referenced object along the way.
Regards,
Ronald
I am not able to provide much help here other than saying that I have run into bugs around auto-commit behaviour as well. But that was when working with Mendix 6, not 7.
I assume you have explained your reasoning on why you are sure your “state B” hypothesis is correct to a number of rubber duckies?