One to one association

Hello Team, I am having two entities A and B,one to one association between them. While creating object of A association is set but after sometime association is getting empty or overwritten. Is there any way to avoid overwrite?
2 answers

Hi Sidheshwari,


Autocommited objects might be the cause of this. Take a look at paragraph 5.2 of this documentation.


In Mendix, if you are experiencing issues where the association between entities A and B is getting overwritten or becoming empty, there could be several reasons for this behavior. Here are some common considerations and potential solutions:

Default Values:Check if you have any default values set for the association in entity A. If there are default values, they might be overwriting the association during the creation of the object.

Microflow Logic:If you are using microflows to create or update objects, make sure that there is no logic in the microflow that unintentionally overwrites or clears the association. Examine the microflow steps to ensure they are not causing the issue.

Validation Rules:Look for any validation rules that might be preventing the association from being set. Validation rules can prevent the object from being committed to the database if certain conditions are not met.

Event Handling:Check any "before commit" or "before persist" events associated with entity A. There might be logic in these events that is modifying the association.

Concurrency Issues:If your application involves concurrent updates, there might be a race condition where multiple transactions are trying to update the association simultaneously. Ensure that your logic handles concurrency appropriately.

Logging:Add logging statements to your microflows or events to track the changes in the association. This can help you identify exactly when and where the association is being overwritten.

Check Default Values in the Domain Model:In the Mendix Domain Model, make sure that there are no default values set for the association itself. Default values at the domain model level can also impact the initial state of associations.

Debugging:Use the Mendix debugger to step through your microflows and events to understand the flow of execution and identify the point where the association is being cleared or overwritten.

By carefully reviewing these aspects of your Mendix application, you should be able to identify the cause of the association being overwritten and take appropriate corrective actions.