Entity pairs with multiple associations: moving to 2.5
Readers may remember that I asked about how to show entities from one association and not the other in a nested datagrid in 2.4.x. The answer was to specify the association as an XPath query and set the context to "Private", which worked. When I converted the project to 2.5 funny things happen when I use the "New" button in a nested datagrid. There is a dataview showing detail of an entity Code such that Code has one to many Rates. There are two associations between the two: Rate_Code, which is the Code to which a given Rate belongs; and pre_Rate_Code, which is the Code it used to belong to before the last change. In the data view there is a datagrid that is supposed to show all the Rates for which Rate_Code is the Code shown in the enclosing dataview. If I click on New at the top of the datagrid I get a detail form which I've defined to populate a new Rate, which is fine. But the system doesn't associate the new Rate object with the enclosing Code object, which it did automatically in 2.4.x. If I create objects some other way (loading them in from file) things look fine, and it also seems OK if there is just one association. Looking at the database, it's apparent that the child object is being created and saved but the association to the parent object isn't. How can I get it to create the association correctly?
Answered it myself :-)
You have to select the path under "Entity (path)" in the "Data source" section of the properties for the nested dataview; it defaults to just the entity name so it presumably doesn't know which association to use.