Introduced in version 2.5 (released May 2021), extended in version 2.7 (release September 2021)
Since Mendix 7 the Mendix runtime is stateless and you can run multiple instances on the same database, see scaling in the Mendix cloud for example. Non-persistent objects can be created in microflows and exist during execution in a Mendix runtime. Also the browser maintains a cache of non-persistent objects. However this browser cache is cleared when the object is no longer needed. This can be on closing a page or after some time or on switch a row in a grid. Also, when the microflow retrieves the persistent entity from the database the association from the non-persistent entity is not linked to this copy.
Therefore you can use following associations in a retrieve by association:
- Persistent to persistent, because data is in the database
- Non-persistent to non-persistent, because all data is in the browser
- Non-persistent to persistent, because your browser non-persistent refers to a database record
Non-compliant examples
Compliant example
How to solve a violation
This violation is in the architecture section, because it is harder to resolve. You can consider redesigning the page and have a container non-persistent object that keeps references to all needed non-persistent objects.
In essence the best practice is that going from persistent to non-persistent should be avoided at all times.