How to access entities in java?

I have two entities A and B with a one to many relation from A to B. In the java code I have an instance of A. How can I get all the B's which are associated with the given instance of A?
1 answers

That is a simple as:

List<B> blist = A.getYourAssocNameFromAtoB();

If you are using Eclipse, Ctrl+ Space is your friend. If you are not using Eclipse, you should.


The reference is not stored on the A side, so its not directlty accessible there. You should use the core.retrieveXPathQuery api.

For example:

List<IMendixObject> Bs = Core.retrieveXPathQuery(this.getContext(), String.format("//%s[%s= %s]", B.getType(), B.MemberNames.A_B, a.getMendixObject().getId().getGuid());

Optionally you can loop afterwards to instantiatie proxies for B.