Fixing OData/Olingo error: “Could not find an entity set or function import for ‘x’.”

Sometimes with Apache Olingo you see this error message:

Could not find an entity set or function import for 'my_table'.

The Olingo sample applications register types like so:

static final String 
  ENTITY_SET_NAME_CARS = "Cars";

private static final 
  FullQualifiedName ENTITY_TYPE_1_1 = 
    new FullQualifiedName(
      NAMESPACE, 
      ENTITY_NAME_CAR);

...

List entitySets = 
  new ArrayList();

entitySets.add(
  getEntitySet(
    ENTITY_CONTAINER, 
    ENTITY_SET_NAME_CARS));

So, all you need to do to fix this error is to fill out these spots for your new type. To set up EntitySet you can do the following:

new EntitySet()
  .setName(name)
  .setEntityType(
    new FullQualifiedName(NAMESPACE, name)
   )

Note that you may want to use different values for ‘setName’ and ‘entityType’ – in the sample apps they use the pluralized form in setName and the singular in entity type.

Leave a Reply

Your email address will not be published. Required fields are marked *