If you recieve an Any Object you could say:
iMendixObject.getMetaObject()
in the loop.
iMendixObject is your parameter to your java action of type Any Object.
also you probably need
Core.commit(definitie .getMendixObject());
Pass anyobject (in this case called MyEntity) and use
for (IMetaPrimitive metaPrimitive : MyEntity.getMetaObject().getMetaPrimitives())