code: public static String formatEntityKey(EntityDataModel entityDataModel, Object entity) throws ODataEdmException {
  
          Key entityKey = getAndCheckEntityType(entityDataModel, entity.getClass()).getKey();
          List<PropertyRef> keyPropertyRefs = entityKey.getPropertyRefs();
          try {
              if (keyPropertyRefs.size() == 1) {
                  return getKeyValueFromPropertyRef(entityDataModel, entity, keyPropertyRefs.get(0));
              } else if (keyPropertyRefs.size() > 1) {
                  List<String> processedKeys = new ArrayList<>();
                  for (PropertyRef propertyRef : keyPropertyRefs) {
                      processedKeys.add(String.format("%s=%s", propertyRef.getPath(),
                              getKeyValueFromPropertyRef(entityDataModel, entity, propertyRef)));
                  }
                  return processedKeys.stream().map(Object::toString).collect(Collectors.joining(","));
              } else {
                  LOG.error("Not possible to retrieve entity key for entity " + entity);
                  throw new ODataEdmException("Entity key is not found for " + entity);
              }
          } catch (IllegalAccessException e) {
              LOG.error("Not possible to retrieve entity key for entity " + entity);
              throw new ODataEdmException("Not possible to retrieve entity key for entity " + entity, e);
          }
      }
docs: Get the entity key for a given entity by inspecting the Entity Data Model.
  
  @param entityDataModel The Entity Data Model.
  @param entity          The given entity.
  @return The String representation of the entity key.
  @throws ODataEdmException If unable to format entity key