code: @SuppressWarnings("unchecked")
    public <E> E update(E entity) {
      try {
        entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entity);
        Intent intent = (nativeWriter instanceof Batch) ? Intent.BATCH_UPDATE : Intent.UPDATE;
        Entity nativeEntity = (Entity) Marshaller.marshal(entityManager, entity, intent);
        nativeWriter.update(nativeEntity);
        E updatedEntity = (E) Unmarshaller.unmarshal(nativeEntity, entity.getClass());
        entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntity);
        return updatedEntity;
      } catch (DatastoreException exp) {
        throw DatastoreUtils.wrap(exp);
      }
  
    }
docs: Updates the given entity in the Cloud Datastore. The passed in Entity must have its ID set for
  the update to work.
  
  @param entity
  the entity to update
  @return the updated entity.
  @throws EntityManagerException
  if any error occurs while updating.