jmix icon indicating copy to clipboard operation
jmix copied to clipboard

Entity changes are not preserved in the UI when reopening its detail view

Open OLODiman11 opened this issue 3 months ago • 1 comments

Environment

Jmix version: 2.7.0

Bug Description

Entity changes are not preserved in the UI when reopening its detail view

Steps To Reproduce

  1. Run sample project
  2. Navigate to As
  3. Create entity A with name A1
  4. Create entity B with name B1
  5. Create entity C with name C1
  6. Create entity D with name D1
  7. Save everything Now you should have the following relation: A1 > B1 > C1 > D1
  8. Open edit view for A1
  9. Edit B1, change its name to B2
  10. Click Ok in the B view (do not close A1 view)
  11. Edit B2 again (that was previously B1)
  12. The name remains B1 in 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

fetch-plan-bug.zip

OLODiman11 avatar Nov 24 '25 13:11 OLODiman11

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.

knstvk avatar Dec 09 '25 13:12 knstvk