One way to resolve this issue is to use a many-to-many association, so browsing through the association will enable you to achieve this goal.
I found out a solution.
I had to make the association between Person and Phone as * – * and navigability refer each other.
Then on java, you can create a list of Phone and attach it to the person entity you need.
In Mendix java action, my return was set to Object of Person, then inside the java action you need to use method person.getMendixObject() as the return.
You would normally use the proxy classes to do this.
So assuming you have an entity called Test in MyFirstModule, with an attribute called Name, and your IMendixObject is TestIMendixObject, something like this should work.
Test test = myfirstmodule.proxies.Test.initialize(getContext(), TestIMendixObject);
test.setName("my test object");
Hope this helps.
If you’re setting a reference set (many-to-many), you’re looking for the setValue method on the IMendixObject. If you’re unsure about what to set the value to, try using getValue to read a current value so you can match it.
If you’re setting a reference (many-to-one), you need to iterate through each Phone proxy object or IMendixObject to set the association.