Update an entity's DB row by its ID.
Set the updated timestamp column if it exists.

@param  AbstractEntity $entity
@param  array          $values Values to set on the entity
175792
protected function updateRow(AbstractEntity $entity)
    {
        $values = $entity->getDbValues();

        $query = $this->getSqlObject()
            ->update()
            ->set($values)
            ->where($this->getPrimaryKeyWheres($entity));

        $this->execute($query);
    }
678476
public function setEntities(array $entities)
    {
        foreach ($entities as $entity) {
            if (! $entity instanceof AbstractEntity) {
                $message = sprintf(
                    'Expected an array of entities. Array contains element of type %s.',
                    gettype($entity)
                );

                throw new InvalidArgumentException($message);
            }
        }

        $this->entities = $entities;
    }
143443
public function update($entity)
    {
        $data = $this->mapper->toDbTableRow($entity);
        $this->specificationQuery->update($data->toArray());
        return true;
    }
782183
@SuppressWarnings("unchecked")
	@Override
	public int update(final Object entity) {
		@SuppressWarnings("rawtypes")
		EntityHandler handler = this.getEntityHandler();
		if (!handler.getEntityType().isInstance(entity)) {
			throw new IllegalArgumentException("Entity type not supported");
		}

		try {
			Class<?> type = entity.getClass();
			TableMetadata metadata = handler.getMetadata(this.transactionManager, type);
			SqlContext context = handler.createUpdateContext(this, metadata, type, true);
			context.setSqlKind(SqlKind.UPDATE);
			handler.setUpdateParams(context, entity);
			int count = handler.doUpdate(this, context, entity);

			if (count == 0 && MappingUtils.getVersionMappingColumn(type).isPresent()) {
				throw new OptimisticLockException(context);
			}
			return count;
		} catch (SQLException e) {
			throw new EntitySqlRuntimeException(SqlKind.UPDATE, e);
		}
	}
1354373
public function persist(AbstractEntity $entity)
    {
        /** @var InserterTrait $this */
        if ($entity->isNew()) {
            return $this->insert($entity);
        }

        /** @var UpdaterTrait $this */
        return $this->update($entity);
    }
946367
public void update(Entity entity) {
        entityCache.put(entity,
                        false); // false -> we don't store state, meaning it will always be seen as changed
        entity.setUpdated(true);
    }
265573
public function setValue($entity, $columnDescriptorId, $value, AutoTablesConfiguration $config) {
        Ensure::isNotNull($entity, 'entity musst not be null');
        $columnDescriptor = $this->getColumnDescriptor($entity, $columnDescriptorId, $config);
        if ($columnDescriptor->getType() == 'datetime') {
            $format = $this->translator->trans('php.date.format', array(), $config->getTransScope());
            $date = \DateTime::createFromFormat($format, $value);
            $columnDescriptor->setValue($entity, $date);
        } else {
            $columnDescriptor->setValue($entity, $value);
        }
    }
170218
public function updateEntityById($entity, $bind, $id)
    {
        $tbl = $this->resource->getTableName($entity);
        if ($bind instanceof DataObject) {
            $data = $bind->get();
        } else {
            $data = $bind;
        }
        $where = '1';
        foreach ($id as $field => $value) {
            $where .= " AND $field=" . $this->conn->quote($value);
        }
        $result = $this->conn->update($tbl, $data, $where);
        return $result;
    }
1056001
private function doUpdateByQueries(array $row): void
    {
        $data = $this->generateFakeData();

        $queryBuilder = $this->dbUtils->getConn()->createQueryBuilder();
        $queryBuilder = $queryBuilder->update($this->entity);
        foreach ($data as $field => $value) {
            $value = empty($row[$field]) ?
                $this->dbUtils->getEmptyValue($this->entityCols[$field]['type']) :
                $value;

            $condition = $this->dbUtils->getCondition($field, $this->entityCols[$field]);
            $queryBuilder = $queryBuilder->set($field, $condition);
            $queryBuilder = $queryBuilder->setParameter(":$field", $value);
        }
        $queryBuilder = $queryBuilder->where("{$this->priKey} = :{$this->priKey}");
        $queryBuilder = $queryBuilder->setParameter(":{$this->priKey}", $row[$this->priKey]);

        $this->returnRes === true ?
            array_push($this->queries, $this->dbUtils->getRawSQL($queryBuilder)) :
            null;

        if ($this->pretend === false) {
            $queryBuilder->execute();
        }
    }
1286047
public function refresh($entity)
    {
        $fields = $this->getFields();

        foreach ($fields as $key => $mapping) {
            $fieldType = $this->fieldManager->get($mapping['fieldtype'], $mapping);
            $getter = 'get' . ucfirst($key);
            $value = $entity->$getter();
            if ($value) {
                $fieldType->set($entity, $value);
            }
        }
    }
507803
protected function prepareEntityForPersist(AbstractEntity $entity): bool
    {
        if ($entity instanceof TimestampableInterface) {
            $entity->setEditionDate(new DateTime());
        }

        return true;
    }
119045
public function setData($entity)
    {
        if ($this->accessor == null) {
            $this->accessor = new PropertyAccessor;
        }

        foreach ($this->getFields() as $field) {
            if (is_object($field)) {
                if (($mapping = $field->getMappingName()) && !$field->readOnly()) {
                    if (is_array($entity)) {
                        if (isset($entity[$mapping])) {
                            $field->setValue($entity[$mapping], 1);
                        }
                    } else {
                        $value = $this->accessor->getValue($entity, $mapping);
                        $field->setValue($value, 1);
                    }
                }
            }
        }
    }
703503
public function update($entity)
    {
        $eloquentModel = $this->getEloquentModel($entity, true);

        $this->updateRelations($eloquentModel, 'update');

        $eloquentModel->save();

        $eloquentModel->afterSaving($entity, 'update');
    }
243096
public function setNewValue($field, $value)
    {
        $this->assertValidField($field);

        $this->entityChangeSet[$field][1] = $value;
    }
332489
function setValue($entity, $value)
    {
        switch ($this->format)
        {
            case 'scalar':
                $this->property->setValue($entity, $value);
                break;

            //Unserialize classes and arrays before putting them back in the entity.
            case 'object':
            case 'array':
                $this->property->setValue($entity, unserialize($value));
                break;

            //Decode Json from DB back into a regular assoc array before putting it into the entity.
            case 'json':
                $this->property->setValue($entity, json_decode($value, true));
                break;

            //Create a date time object out of the db stored date before putting it into the entity.
            case 'date':
                $date = null;
                if ($value) {
                    $date = new \DateTime($value . ' UTC');
                    $date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                }

                $this->property->setValue($entity, $date);
                break;
        }
    }
9009
public void updateMappedByEntities(
      @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity) {
    entity
        .getEntityType()
        .getMappedByAttributes()
        .forEach(
            mappedByAttr -> {
              AttributeType type = mappedByAttr.getDataType();
              if (type != ONE_TO_MANY) {
                throw new RuntimeException(
                    format(
                        "Attribute [%s] of type [%s] can't be mapped by another attribute",
                        mappedByAttr.getName(), type.toString()));
              }
              updateMappedByEntitiesOneToMany(entity, existingEntity, mappedByAttr);
            });
  }
925063
public function update($entity)
    {
        if (!$entity instanceof $this->entityClass) {
            throw new \InvalidArgumentException(
                "The entity to be updated must be an instance of {$this->entityClass}."
            );
        }

        $entityId = $entity->id;
        $data = $entity->toArray();
        unset($data['id']);

        return $this->adapter->update($this->entityTable, $data, "id = $entityId");
    }