<-- Back

Transaction failure after upgrading to Studio Pro v11: Autocommitted objects detected at end of transaction for volatile session for entities

Issue

While saving a transaction for an entity through Application Programming Interface (API) processing, the application explicitly commits all associated objects, but still encounters the following error:

Autocommitted objects detected at end of transaction for volatile session for entities

For example, when submitting fifteen API requests, thirteen transactions are created successfully, while two fail with the above error. The runtime error references the specific entities being autocommitted, such as:

MyModule.ParentEntity: 1 instance
MyModule.ChildEntity: 2 instances

This behavior occurs after upgrading from Studio Pro v10.24.13, where the same implementation works without issues, to Studio Pro v11.12.1. The affected entities have one-to-one associations, and in the implementation the child object is committed first, followed by the parent object.

Environment

Studio Pro v11.12.1 and newer

Cause

As of Studio Pro v11, the Mendix Runtime has become stricter and more consistent in maintaining the auto-commit condition. This behavior change causes implementations that relied on the previous, more lenient auto-commit handling to fail with the autocommitted objects error, even when they work in Studio Pro v10.

Autocommitted objects occur when an association is set to a new object, the associated object is committed, and all of its associations are committed as well to keep the data consistent. This can happen when:

  • An object that has an association to these entities is committed and the association owner is the committed object, causing autocommit of the associated objects (check the ownership of the association).
  • A before or after commit event handler on another entity modifies or creates these objects.
  • A parent is committed before committing its associated children (check the order of the commits).

Solution/Workaround

For projects where the stricter Studio Pro v11 auto-commit behavior would otherwise be a breaking change, the Autocommit.MaintainAutoCommitCondition custom runtime setting restores the previous behavior. Follow these steps:

  1. Set the Autocommit.MaintainAutoCommitCondition custom runtime setting to false.
  2. Stop and start the application to ensure the setting takes effect.
  3. Retry the affected scenario and confirm that the error no longer occurs.

This setting is the supported fix for this scenario.

In addition, it is good practice to review the implementation to avoid autocommitted objects:

  • Check the ownership of the associations involved (set the association owner from Both to Default when only one side of the association needs to be the owner).
  • Review the order of commits, ensuring children are committed before their parents.
  • Compare the working requests with the failing ones to identify differences.

Internal information related

  • 283801
  • RUN-3235

  • C3T260XGA/p1785854840096529

Additional information

Mendix documentation: Committing Objects

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.