There is a problem with load() method and data containers commit in which after the load() method is called once to load a certain collection, the data container will be loaded with all the properties even though the view set on the corresponding data container does not contain all those properties. I believe there has something to do with the dataContext merge in the load() implementation.
Before the load method is called, if I try in debugger to fetch a property which is not present in the view, it throws [IllegalStateException: Cannot get unfetched…] which is ok, but after the load() method is called, when I try to fetch the same property it does not throw any errors and it shows the current value of the property, which is not ok.
We have a VERY BIG PROBLEM in our enterprise solution where properties are set to null and persisted into the database. If the entity is passed to the service layer after a call of the method load(), on the next dataContext commit the value of null is set to all those properties that are not present into the view of the data container in the xml descriptor. That means we should always include all the properties into the view, which kind of defies the purpose of views.
I have extended the cuba-petclinic project with services and a Status property on the Person entity to be able to show the problem. I have also made a video where you can see how the Status property on the Employee is being set to null after editing the entity twice (on the second edit dataContext.commit() persist null on properties, after the load() method is called in first edit).
Thank you for the report, I have filed an issue.
Until it is resolved, you can work around the problem by clearing the DataContext right after commit and before loading it again:
I’ve look into the issue and I have to say is not completely fixed.
It’s been solved for subsequent commit and merge calls. So it works for edit, but still does not work for remove.
If you have subsequent calls of commit and remove, on the second commit call information is still lost.
Unfortunately, I couldn’t reproduce the problem on my tests.
Could you provide more information? What steps lead to the problem?
What information is lost? References in the removed entity?