Search code examples
javaodataolingo

Is it possible to renounce the key property of a Olingo EntityType


Is a key value mandatory while setting up an EntityType?

This may sound a little odd but I have a case where a key is unnecessary. So I was asking myself if I can get rid of these code lines.

        List<PropertyRef> keyProperties = new ArrayList<PropertyRef>();
        keyProperties.add(new PropertyRef().setName("KEY"));
        Key key = new Key().setKeys(keyProperties);

Solution

  • A key is required for an entityType in olingo and odata, because if there is no unique key for an entity then we won't be able to use getEntity (to query the data of just one entity from a given entitySet) on it , as well as navigation properties and $expand will also not behave properly.