Hi, I have found a huge problem with deep bidirectional compositions. I wanted to implement something like Country <-> State <-> City but kept getting erros either in jsps or in the backend. After looking a little deeper I found that the problem was due to the fact that the object references are not updated properly when doing a save through our web context stack. This behaviour will only occur with "ear" deployments since when changing tiers, the references are not kept.
I was looking for a quick fix and found out that it would need a full context stack refactoring. Since this is in our plans anyway, I will wait before I do anything. Recap: ===== The context stack is used for the navigation of compositions through our interfaces. Here is an example of what happens if I want to create a city (through the state and country interface). - We cannot go directly in the City list interface since it is a child of state. - We cannot go directly in State to create the city since it is a child of country - We go in the country list interface - We click on add (to go the country form) - In the country form we enter the name of the country - In the country form there is a add state button. We click on this button (in the backend the context stack is created with the first element being the country). This takes us to the state form. - In the state form we enter the name of the state - In the state form there is a add city button. We click on this button (in the backend the state is added to the context stack...which now has country and state). This takes us to the city form. - In the city form, we enter the name of the city - We then click on the save button. In the backend, this will add the third element to the context stack (city). It will then update the context stack so that the city is added to the state and that the state be added to the country. The country is then saved which will go automatically save the state and the city (since they are children). This works fine in a tomcat environment where all these object references work in a single virtual machine for when the country is saved, all the references are also saved. Quick explanation of the problem: ======================= contextstackelement1: country -> state -> city contextstackelement2: state -> city contextstackelement3: city With our current context stack, we keep the references because they are not necessarily persisted and therefore have no id (we wouldn't be able to find the city in the state if we did not keep its reference.). Therefore, when we save the country, it updates its own references but the other contextstackelements are not updated. This means that when the country is saved, the contextstackelement2 state has no id. Same thing for contextstackelement3 and city. There is something fundamentally wrong with this for we keep all the references in 2 places and have to try to keep them synchronized...I haven't given it enough thought for now but we should be able to come up with a simpler solution. I know this is not perfectly clear but I wanted to keep a trace of this before I dig further. Also if anybody wants to explore this refactoring, you can contact me first so we can have a look at what can be done. As of now I am not sure that the bidirectional compositions have anything to do with the problem. I think we will encounter this problem for all deep compositions. What is for sure, is that the web layer refactoring is getting quite urgent. François PS: By the way, to workaround my problem for now, I have modified the model not to have any deep compositions. I still have Country <-> State <-> City but the last relation is an association. Country has a composition on State. Ugly but temporarily acceptable Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Mdarad-toolbox-devs mailing list Mdarad-toolbox-devs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mdarad-toolbox-devs