Entity changes are not preserved in the UI when reopening its detail view
Environment
Jmix version: 2.7.0
Bug Description
Entity changes are not preserved in the UI when reopening its detail view
Steps To Reproduce
- Run sample project
- Navigate to
As - Create entity
Awith nameA1 - Create entity
Bwith nameB1 - Create entity
Cwith nameC1 - Create entity
Dwith nameD1 - Save everything Now you should have the following relation: A1 > B1 > C1 > D1
- Open edit view for
A1 - Edit
B1, change its name toB2 - Click
Okin theBview (do not closeA1view) - Edit
B2again (that was previouslyB1) - The name remains
B1in the UI
Current Behavior
The name of the B entity remains B1 in the UI
Expected Behavior
The name of the B changes to B2 in the UI
Notes
As i understand it happens because of specific fetch plans
a-detail-view fetch plan:
<fetchPlan extends="_base">
<property name="bs" fetchPlan="_base">
<property name="cs" fetchPlan="_base"/>
</property>
</fetchPlan>
b-detail-view fetch plan:
<fetchPlan extends="_base">
<property name="cs" fetchPlan="_base">
<property name="d" fetchPlan="_base"/>
</property>
</fetchPlan>
When you open a-detail-view it loads all cs and does not load d
When you open b-detail-view it loads all cs and d
When clicking Ok in b-detail-view it merges its context to the a-detail-view context, but it does not mark d as loaded (DataContextimpl#mergeList calls internalMerge with isRoot set to false and eventially it gets to mergeLoadedPropertiesInfo)
Then when opening b-detail-view again it checks if the provided B (from the a-detail-view context) is loaded with a proper fetch plan and fails because it thinks that d is not loaded, so it reloads the entity loosing all the changes made to it.
Sample Project
So the workaround is either to not define unnecessary nested attributes in the root detail view:
<instance id="aDc"
class="com.company.fetchplanbug.entity.A">
<fetchPlan extends="_base">
<property name="bs" fetchPlan="_base"/>
</fetchPlan>
<loader id="aDl"/>
<collection id="bsDc" property="bs"/>
</instance>
Or define them to the full depth:
<instance id="aDc"
class="com.company.fetchplanbug.entity.A">
<fetchPlan extends="_base">
<property name="bs" fetchPlan="_base">
<property name="cs" fetchPlan="_base">
<property name="d" fetchPlan="_base"/>
</property>
</property>
</fetchPlan>
<loader id="aDl"/>
<collection id="bsDc" property="bs"/>
</instance>
The former is obviously better.