Hi all,
Is it somehow possible to specify properties in the fetch plan as read-only?
The background of the question is that as far as I understand each entity in the fetch plan of an edit screen is moved into the dataContext which is a great feature. But sometimes I have a constellation where an entity gets changed and committed in a service independent of the edited entity and by that the committed entity gets changed in the dataContext as well and when the user wants to close the edit screen there is a conflict regarding “entity changed in another transaction”.
An example:
I have a Company and Employees. When I edit an Employee there is a checkbox named “IsBoss”. When I check the box a service is called for the Company that scans Employees, finds the “Boss” and sets it in a field in the Company and commits the company so everyone who opens the company can see who the Boss is immediately.
I call the service like that: companyService.SetBossInCompany(getEditedEntity().getCompany()).
The Company is in the fetch plan of the Employee Edit Screen because I want to show a read only field to which Company the Employee belongs to. That means, the service changes the Company and saves it. The Company also moves to modiefiedInstances in the dataContext and causes the transaction error.
My solution right now is to evict the Company from the dataContext in onAfterShow(), If you say that is perfectly fine can live with that but it feels a bit hacky. So I thought about an attribute for properties that cause the entity not to be placed in the dataContext like this:
Maybe this has also other implications I can’t oversee. I’d be happy to hear your opinion about that!