Add a method to the Java API that returns all modified/uncommitted objects - Mendix Forum

Add a method to the Java API that returns all modified/uncommitted objects


My application has a page that has a single object with many associations to child entities.  When a "Save" button is clicked, my app calls a microflow that receives the single parent object as a parameter.  The save microflow then commits the one parent object, then does MANY retrieves over associations to get the child objects (and the grandchild objects, and the grand-grand-child objects, etc) to commit those objects.  It is often the case that only the parent object, or a single grandchild object has actually been changed.


Unfortunately, each retrieve by association does a database query and as a result my app is performing hundreds of database queries to obtain a list of objects to commit.  This has a noticable impact on performance.


It shouldn't have to be like this.  The only objects that I care about committing are those that are modified.  If I could get a list of modified objects (or even just any cached objects on which I could filter by IMendixObject.isChanged()), I would be able could commit all of the changed objects without any database retrieves (or at least, far fewer).


This list of modified objects is part of the XAS request from the client.  I might try to read the incoming request using this.context().getRuntimeRequest() and pull out the ids of all of the changed objects, load them, and commit them.  But that is lots of work, it repeats something Mendix is likely doing internally, and it doesn't account for objects that have been changed as part of the current request.


Instead, I propose adding a method to the Mendix Java API to retrieve a list of modified (or even just cached objects).  I would guess that such a list is already maintained internally by Mendix or the ORM.  Making it publicly accessible would greatly improve the performance of my app's saves (and auditing).


I would suggest something like Core.getModifiedObjects() returning an Iterable<IMendixObject>.

0 answers