I was hunting for a strange bug for quite a while. Thomas gave me the final hint as to what might be going on.
The effect of what I see is that some changes to object read in a session are not recognized and therefor don't result in UPDATE statements.This potentially leads to catastrophic consequences.
Let me explain:
I have this web application where you can enter a few search criteria to find objects from the db. You can click on "Search" and get a list of objects matching your criteria. You can select one of these list entries and open an edit dialog. After you've changed data, you can click on SAVE and we commit the unit of work.
So far, nothing special is going on. The cheapest, most boring and simple CRUD stuff. Right?
Wrong.
I have the situation where exactly that is NOT happening. You can select the object, open a dialog, change some data, click save and the UOW gets committed. Teh UOW commits successfully, but only because it doesn't issue any UPDATE statements. Because it found no changes between the buisiness object (which definitely has changed, both by values changed in the dialog and by calculations based on the changed input.
The result is that the business objects display wonderfully hanged values in the web browser and inspector, but they are out of sync with the database!!!
I seem to have found the reason.
The funny thing is: if I do all of this in a workspace: load an object by id, change a few values using the setters, commit the UOW, all is fine. But not in the Web App.
The reason seems to be that complex queries do not maintain the undoMap of the current Transaction. I added a bit of inspects and such and I found that when I directly load an object, it and its referenced objects are in the undoMap or the current UOW's transaction. But in case of my web application, they are not.
So what I had to do was to add an extra read to the list when the user selects an object from the list. When I hand this newly read object to the detail dialog, the objects end up in the undoMap and all changes get saved to the database on commit.
What I think is the problem is that the query for the list has a few (up to 8) alsoFetch: es with beOuterJoin's.
So my question: is this intended behavior or a bug?
Joachim