Java retrieval of associated objects

I have two entities, EntityOne and EntityTwo, There is a many to many association between the two entities with the reference stored only on the EntityOne side. In the modeler I have the possibility to retrieve all related EntityOne entries from EntityTwo using the association, how can I do the same thing in Java?! When the reference is stored on both sides I can use the provided method in the proxy class, but no such method is available in the proxy class of EntityTwo when the reference is only stored on the EntityOne side. Ideally I would like to use something like: Object valueObject = getMendixObject().getValue(context, MemberNames.EntityOne_EntityTwo.toString()); This would than return a List of MendixIdentifiers which I want to use. I've also tried: Object valueObject = getMendixObject().getValue(context, EntityOne.getType() + "/" + MemberNames.EntityOne_EntityTwo.toString()); But this results in an IllegalArgumentException. I've searched the ApiDocs up and down but was unable to find any clues as to the way Mendix is doing this, the only place where I could see the association at all was in the IMetaObject using the Core.getMetaObject(ContractParameter1.getMendixObject().getType()).IMetaObject.getDeclaredMetaAssociationsChild() but this also gets me nowhere because I cannot do anything with an IMetaAssociation object. Anyone got a clue as to what to do here?! N.b. Xpath or OQL retrieves will not work here because I want to retrieve the current set (in the user session), I'm also not looking for work-arounds like passing the associated objects to the java action.
1 answers

You can use the Core.retrieveByPath method here, passing the context, starting object and the association name

See the apidocs page

(Note there's also an overloaded method with a boolean for when you're passing a child object of a self association, you probably won't need that)

The javadoc:

   * Retrieves objects using the given object and path.
   * @param context  the context.
   * @param mxObject the start point of the path.
   * @param path     the path (association) to the objects to retrieve.
   * @return the list of retrieved objects.