code: public static Object getId(Object entity, EntityMetadata metadata)
      {
          // If an Entity has been wrapped in a Proxy, we can call the Proxy
          // classes' getId() method
          if (entity instanceof EnhanceEntity)
          {
              return ((EnhanceEntity) entity).getEntityId();
          }
  
          // Otherwise, as Kundera currently supports only field access, access
          // the underlying Entity's id field
  
          return getObject(entity, (Field) metadata.getIdAttribute().getJavaMember());
      }
docs: Get identifier of an entity object by invoking getXXX() method.
  
  
  @param entity
  the entity
  @param metadata
  the metadata
  
  @return the id
  
  @throws PropertyAccessException
  the property access exception