Update by criteria specified as HQL
@param secondHalfOfHql
@param paramValues
@param paramTypes
@return	the number of records updated
484739
public int updateByHql(String secondHalfOfHql, Object[] paramValues, Type[] paramTypes){
    	StringBuilder queryStr = new StringBuilder();
    	queryStr.append("update ")
			.append(this.clazz.getName())
			.append(" ");
    	if (secondHalfOfHql != null){
    		queryStr.append(secondHalfOfHql);
     	}
    	
        Session session = this.getCurrentSession();
    	Query query = session.createQuery(queryStr.toString());
    	setupQuery(query, paramValues, paramTypes, null, null);
        return query.executeUpdate();
    }
1276606
public List< T> getAllByHql(String secondHalfOfHql, Object paramValue, Type paramType) {
        return getAllByHql(secondHalfOfHql, new Object[] {paramValue}, new Type[]{paramType}, null, null);
    }
43148
public static ModifyType detectModifyType(SQLiteModelMethod method, JQLType jqlType) {
		// Elements elementUtils = BaseProcessor.elementUtils;
		SQLiteDaoDefinition daoDefinition = method.getParent();
		SQLiteEntity entity = method.getEntity();

		ModifyType updateResultType = null;

		// check type of arguments
		int count = 0;
		for (Pair<String, TypeName> param : method.getParameters()) {
			if (method.isThisDynamicWhereConditionsName(param.value0)) {
				// if current parameter is dynamic where, skip it
				continue;
			}

			if (TypeUtility.isEquals(param.value1, typeName(entity.getElement()))) {
				count++;
			}
		}

		if (count == 0) {
			// method to update raw data: no bean is used
			updateResultType = jqlType == JQLType.UPDATE ? ModifyType.UPDATE_RAW : ModifyType.DELETE_RAW;

			ModelAnnotation annotation;

			if (jqlType == JQLType.UPDATE) {
				annotation = method.getAnnotation(BindSqlUpdate.class);

				AssertKripton.assertTrueOrInvalidMethodSignException(
						AnnotationUtility.extractAsStringArray(method, annotation, AnnotationAttributeType.FIELDS)
								.size() == 0,
						method, " can not use attribute %s in this kind of query definition",
						AnnotationAttributeType.FIELDS.getValue());
				AssertKripton
						.assertTrueOrInvalidMethodSignException(
								AnnotationUtility.extractAsStringArray(method, annotation,
										AnnotationAttributeType.EXCLUDED_FIELDS).size() == 0,
								method, " can not use attribute %s in this kind of query definition",
								AnnotationAttributeType.EXCLUDED_FIELDS.getValue());

			} else {
				annotation = method.getAnnotation(BindSqlDelete.class);
			}

			// check if there is only one parameter
			AssertKripton.failWithInvalidMethodSignException(method.getParameters().size() > 1
					&& TypeUtility.isEquals(method.getParameters().get(0).value1, daoDefinition.getEntityClassName()),
					method);

		} else if (count == 1) {
			updateResultType = jqlType == JQLType.UPDATE ? ModifyType.UPDATE_BEAN : ModifyType.DELETE_BEAN;

			// with dynamic where conditions, we have to add 1 to parameter
			// check size (one parameter is a bean and one is the where
			// conditions)
			AssertKripton.assertTrueOrInvalidMethodSignException(
					method.getParameters().size() == 1 + (method.hasDynamicWhereConditions() ? 1 : 0)
							+ (method.hasDynamicWhereArgs() ? 1 : 0),
					method, " expected only one parameter of %s type", daoDefinition.getEntityClassName());
		} else {
			throw (new InvalidMethodSignException(method,
					"only one parameter of type " + typeName(entity.getElement()) + " can be used"));
		}
		return updateResultType;
	}
718626
@Transactional
  @PostMapping(
      value = "/{entityTypeId}/{id}",
      params = "_method=PUT",
      headers = "Content-Type=application/x-www-form-urlencoded")
  @ResponseStatus(NO_CONTENT)
  public void updateFromFormPost(
      @PathVariable("entityTypeId") String entityTypeId,
      @PathVariable("id") String untypedId,
      HttpServletRequest request) {
    Map<String, Object> paramMap = new HashMap<>();
    for (String param : request.getParameterMap().keySet()) {
      String[] values = request.getParameterValues(param);
      String value = values != null ? StringUtils.join(values, ',') : null;
      paramMap.put(param, value);
    }

    updateInternal(entityTypeId, untypedId, paramMap);
  }
337025
private void setupQuery(Query query, Object[] paramValues, Type[] paramTypes, Integer offset, Integer limit){
    	if (paramValues != null && paramTypes != null){
        	query.setParameters(paramValues, paramTypes);
    	}
    	if (offset != null){
        	query.setFirstResult(offset);
    	}
    	if (limit != null){
        	query.setMaxResults(limit);
    	}
    }
844054
static Map<String, List<Integer>> updateParameterNamesToIndexes(Map<String, List<Integer>> parametersNameToIndex,
                                                                    List<ArrayParameter> arrayParametersSortedAsc) {
        for(Map.Entry<String, List<Integer>> parameterNameToIndexes : parametersNameToIndex.entrySet()) {
            List<Integer> newParameterIndex = new ArrayList<>(parameterNameToIndexes.getValue().size());
            for(Integer parameterIndex : parameterNameToIndexes.getValue()) {
                newParameterIndex.add(computeNewIndex(parameterIndex, arrayParametersSortedAsc));
            }
            parameterNameToIndexes.setValue(newParameterIndex);
        }

        return parametersNameToIndex;
    }
703355
private void updateCache(int index, QueryParameters params) {
        if (generatedCacheMap.containsKey(index) == true) {
            this.generatedCacheMap.put(index, params);
        } else {
            this.resultSetCacheMap.put(index, params);
        }
    }
89220
public static function updateRecord($primaryKey, $fieldValues)
    {
        if (!is_scalar($primaryKey)) {
            throw new InvalidArgumentException(['`:value` is not a valid primary key value', 'value' => $primaryKey]);
        }

        $instance = new static();
        return static::query()->whereEq($instance->getPrimaryKey(), $primaryKey)->update($fieldValues);
    }
389693
public List< T> getAllBySql(String fullSql, Object[] paramValues, Type[] paramTypes) {
        return getAllBySql(fullSql, paramValues, paramTypes, null, null);
    }
123598
public static int update(Connection connection, String table,
			ContentValues values, String whereClause, String[] whereArgs) {

		StringBuilder update = new StringBuilder();
		update.append("update ").append(CoreSQLUtils.quoteWrap(table))
				.append(" set ");

		int setValuesSize = values.size();
		int argsSize = (whereArgs == null) ? setValuesSize
				: (setValuesSize + whereArgs.length);
		Object[] args = new Object[argsSize];
		int i = 0;
		for (String colName : values.keySet()) {
			update.append((i > 0) ? "," : "");
			update.append(CoreSQLUtils.quoteWrap(colName));
			args[i++] = values.get(colName);
			update.append("=?");
		}
		if (whereArgs != null) {
			for (i = setValuesSize; i < argsSize; i++) {
				args[i] = whereArgs[i - setValuesSize];
			}
		}
		if (whereClause != null) {
			update.append(" WHERE ");
			update.append(whereClause);
		}
		String sql = update.toString();

		PreparedStatement statement = null;

		int count = 0;
		try {
			statement = connection.prepareStatement(sql);
			setArguments(statement, args);
			count = statement.executeUpdate();
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to execute SQL update statement: " + sql, e);
		} finally {
			closeStatement(statement, sql);
		}

		return count;
	}
541090
@Override
    public int getSqlType(String paramName) {
        if (!hasValue(paramName)) {
            return TYPE_UNKNOWN;
        }
        Object value = getValue(paramName);
        return StatementCreatorUtils.javaTypeToSqlParameterType(value.getClass());
    }
155951
public long countBySql(String fullSql, Object[] paramValues, Type[] paramTypes){
        Session session = this.getCurrentSession();
    	Query query = session.createSQLQuery(fullSql);
    	setupQuery(query, paramValues, paramTypes, null, null);
        return ((Number)query.uniqueResult()).longValue();
    }
1295013
@SuppressWarnings("unchecked")
  protected <E> List<E> updateWithOptimisticLockInternal(List<E> entities,
      PropertyMetadata versionMetadata) {
    Transaction transaction = null;
    try {
      entityManager.executeEntityListeners(CallbackType.PRE_UPDATE, entities);
      Entity[] nativeEntities = toNativeEntities(entities, entityManager, Intent.UPDATE);
      // The above native entities already have the version incremented by
      // the marshalling process
      Key[] nativeKeys = new Key[nativeEntities.length];
      for (int i = 0; i < nativeEntities.length; i++) {
        nativeKeys[i] = nativeEntities[i].getKey();
      }
      transaction = datastore.newTransaction();
      List<Entity> storedNativeEntities = transaction.fetch(nativeKeys);
      String versionPropertyName = versionMetadata.getMappedName();

      for (int i = 0; i < nativeEntities.length; i++) {
        long version = nativeEntities[i].getLong(versionPropertyName) - 1;
        Entity storedNativeEntity = storedNativeEntities.get(i);
        if (storedNativeEntity == null) {
          throw new OptimisticLockException(
              String.format("Entity does not exist: %s", nativeKeys[i]));
        }
        long storedVersion = storedNativeEntities.get(i).getLong(versionPropertyName);
        if (version != storedVersion) {
          throw new OptimisticLockException(
              String.format("Expecting version %d, but found %d", version, storedVersion));
        }
      }
      transaction.update(nativeEntities);
      transaction.commit();
      List<E> updatedEntities = (List<E>) toEntities(entities.get(0).getClass(), nativeEntities);
      entityManager.executeEntityListeners(CallbackType.POST_UPDATE, updatedEntities);
      return updatedEntities;

    } catch (DatastoreException exp) {
      throw DatastoreUtils.wrap(exp);
    } finally {
      rollbackIfActive(transaction);
    }

  }
726577
@Override
	public int update(Extensions extensions) throws SQLException {

		UpdateBuilder<Extensions, Void> ub = updateBuilder();
		ub.updateColumnValue(Extensions.COLUMN_DEFINITION,
				extensions.getDefinition());
		ub.updateColumnValue(Extensions.COLUMN_SCOPE, extensions.getScope()
				.getValue());

		setUniqueWhere(ub.where(), extensions.getExtensionName(), true,
				extensions.getTableName(), true, extensions.getColumnName());

		PreparedUpdate<Extensions> update = ub.prepare();
		int updated = update(update);

		return updated;
	}
1080403
static final void hipAndKxQIncrementalUpdate(final AbstractHllArray host, final int oldValue,
      final int newValue) {
    assert newValue > oldValue;
    final int configK = 1 << host.getLgConfigK();
    //update hipAccum BEFORE updating kxq0 and kxq1
    double kxq0 = host.getKxQ0();
    double kxq1 = host.getKxQ1();
    host.addToHipAccum(configK / (kxq0 + kxq1));
    //update kxq0 and kxq1; subtract first, then add.
    if (oldValue < 32) { host.putKxQ0(kxq0 -= invPow2(oldValue)); }
    else               { host.putKxQ1(kxq1 -= invPow2(oldValue)); }
    if (newValue < 32) { host.putKxQ0(kxq0 += invPow2(newValue)); }
    else               { host.putKxQ1(kxq1 += invPow2(newValue)); }
  }
760053
public void update(Object[] newValues, boolean updateOutOnly) {
        AssertUtils.assertNotNull(newValues);

        if (newValues.length != this.values.size()) {
            throw new IllegalArgumentException(ERROR_INCORRECT_LENGTH);
        }

        this.assertIncorrectOrder();

        String parameterName = null;
        for (int i = 0; i < newValues.length; i++) {
            parameterName = this.getNameByPosition(i);

            if (updateOutOnly == false || isOutParameter(parameterName) == true) {
                parameterName = this.getNameByPosition(i);

                this.updateValue(parameterName, newValues[i]);
            }
        }
    }
160995
public static String buildEqualsWhere(Entity entity, List<Object> paramValues) {
		if (null == entity || entity.isEmpty()) {
			return StrUtil.EMPTY;
		}

		final StringBuilder sb = new StringBuilder(" WHERE ");
		boolean isNotFirst = false;
		for (Entry<String, Object> entry : entity.entrySet()) {
			if (isNotFirst) {
				sb.append(" and ");
			} else {
				isNotFirst = true;
			}
			sb.append("`").append(entry.getKey()).append("`").append(" = ?");
			paramValues.add(entry.getValue());
		}

		return sb.toString();
	}