1. Retrieve the Parent (Hoge) from a Fuga object
List<IMendixObject> hogeList = Core.retrieveByPath(context, fuga, "MyFirstModule.Fuga_Hoge"); IMendixObject hoge = hogeList.isEmpty() ? null : hogeList.get(0);
Replace "MyFirstModule.Fuga_Hoge"
with your real association name.
The method always returns a list, even for one-to-one or many-to-one relations.
If the list is empty, there’s no associated object.
2. Retrieve All Hoges from a List of Fugas
Set<IMendixObject> uniqueHoges = new HashSet<>(); for (IMendixObject fuga : fugaList) { List<IMendixObject> hoges = Core.retrieveByPath(context, fuga, "MyFirstModule.Fuga_Hoge"); uniqueHoges.addAll(hoges); }
Loops through each Fuga and collects all unique Hoge objects.
Useful if you need all parent records linked to multiple children.
3. Retrieve All Fugas from a Hoge (reverse direction)
List<IMendixObject> fugaList = Core.retrieveByPath(context, hoge, "MyFirstModule.Hoge_Fuga");
This gives you all child Fuga objects linked to a single Hoge.