Hi there, I am using a Java Action to take in a MasterObject entity as parameter. This Java action has a ChildObject entity associated with it. The MasterObject has an Attribute which is of type string and stores an XML string. In the Java Action I am doing the following byte byteArray = masterObject.getResponseString().getBytes(); ByteArrayInputStream bisStream = new ByteArrayInputStream(byteArray); Core.importXmlStream(this.getContext(), bisStream, "MyModule.xtdmMapToChildObject", masterObject.getMendixObject()); Core.commit(this.getContext(), masterObject.getMendixObject()); The XmlToDomainMapping (xtdmMapToChildObject) takes in MasterObject as parameter and maps the XML to a newly created ChildObject. When will all of this get committed to the database? The masterObject.getMasterObject_ChildObject().getMendixObject() method only returns null. And if I do a retrieve action after the Java action, on the MasterObject's association to the ChildObject, it also returns null. BUT, if I retrieve the exact same MasterObject and then retrieve the ChildObject, I get back the Child Object that got created by the XML to Domain Mapping. could somebody please explain this to me? I'm not sure what I am doing wrong. All I want to do is pass through the Parent object, map the xml string value to the domain and return the child object. Kind Regards
This has to do with the way associations and changes are committed in the XML importer. These are batched, for performance reasons, which means that objects that are in your scope won't be updated.
So, the answer is: the objects will have been committed when the "Core.importXmlStream" call returns, BUT the changes will not be reflected immediately in the object you used as a parameter. The fix is the one you're using right now: simply retrieve the master object again.