I am trying to build a createEntity
OEntity for an object that has multiple child collections within it.
I have looked over many of the example projects, but they all seem to assume that you have a known number of child objects in a collection so that you can use .inLine(“ObjectName”, ObjectOEntity1, ObjecteOEntity2…)
I have tried looking at the documentation and have not identified anything that leads me to think I can create a collection of OEntity objects that can then be added to my parent object with the inline.
The closest I found was the example listed on:
Has anyone else run into this problem?
If so how did you get around it?
You can pass in an array of OEntity
objects. The core4j library that is used by odata4j contains some helper methods that can - for example - be used to get an array from an Iterable
:
OEntity[] entitiesArray = Enumerable.create(entitiesIterable)
.toArray(OEntity.class);
But as there are also two variants of the properties method...
OCreateRequest<T> properties(OProperty<?>... props);
OCreateRequest<T> properties(Iterable<OProperty<?>> props);
... it might make sense to add an inline
method that directly takes an Iterable<OEntity>
.