Get association in JAVA

I am trying to get an association within my JAVA code. I already have the Subscription object in my code and want to retrieve the list of SubscriptionItems. It seems there is no getter for this relationship on the Object.   I was looking into retrieveByPath but I’m not able to get it working. Any help is really appreciated. I am fairly new to Mendix. (Working within a microflow is not an option for this). private List<SubscriptionItem> getSubscriptionItems(Subscription subscription) { List<SubscriptionItem> subscriptionItems = new ArrayList<SubscriptionItem>(); List<IMendixObject> results = com.mendix.core.Core.retrieveByPath(subscription.getContext(), subscription.getMendixObject(), ""); // what path? // cast results to subscriptionItems? return subscriptionItems; }  
2 answers

I’d use the proxy class to get the value, so I think something like this should work, but you will probably have to adjust the namespace to match your module name.

List<IMendixObject> results = Core.retrieveByPath(this.getContext(), subscription.getMendixObject(), subscriptionmodule.proxies.SubscriptionItem.MemberNames.SubscriptionItem_Subscription.toString()

Hope this helps.


Here an example I implemented:

List<IMendixObject> documents= Core.retrieveXPathQuery(getContext(),
"//DownloadArea.MediaFile[DownloadArea.MediaFile_Season = "+id+ "]",
batchSize, offset, sort);