Interface UpdateExpression<T>

Type Parameters:
T - The database entity this update applies to.
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface UpdateExpression<T>
Represents an operation on a field of a database entity. Used by the database proxy to apply changes to fields of a table row. See the FieldUpdate class for more info.
  • Method Details

    • apply

      jakarta.persistence.criteria.Expression<T> apply(jakarta.persistence.criteria.Expression<T> currentValue, jakarta.persistence.criteria.Root<?> queryRoot, jakarta.persistence.criteria.CriteriaBuilder cb)
      Applies an update to the value of the current field represented by a JPA expression.
      Parameters:
      currentValue - The JPA expression representing the current value of the field.
      queryRoot - The JPA query root.
      cb - The JPA criteria builder.
      Returns:
      A JPA expression representing the updated value.
    • setTo

      static <V> UpdateExpression<V> setTo(V literal)
      Creates an update expression setting the value of a field to the given value.
      Type Parameters:
      V - The type of the value.
      Parameters:
      literal - The value to set the field to.
      Returns:
      The update expression.
    • add

      static <N extends Number> UpdateExpression<N> add(N number)
      Creates an update expression adding a number onto the current value of the field
      Type Parameters:
      N - The type of the number.
      Parameters:
      number - The number to add onto the current value.
      Returns:
      The update expression.
    • subtract

      static <N extends Number> UpdateExpression<N> subtract(N number)
      Creates an update expression subtracting a number onto the current value of the field.
      Type Parameters:
      N - The type of the number.
      Parameters:
      number - The number to add onto the current value.
      Returns:
      The update expression.
    • multiply

      static <N extends Number> UpdateExpression<N> multiply(N number)
      Creates an update expression multiplying the field by the given number.
      Type Parameters:
      N - The type of the number.
      Parameters:
      number - The number to multiply the current value by.
      Returns:
      The update expression.
    • divide

      static <N extends Number> UpdateExpression<Number> divide(N number)
      Creates an update expression dividing the field by the given number.
      Type Parameters:
      N - The type of the number.
      Parameters:
      number - The number to divide the current value by.
      Returns:
      The update expression.
    • raiseToThePowerOf

      static <N extends Number> UpdateExpression<Double> raiseToThePowerOf(N number)
      Creates an update expression raising the value of a field by the power of the given number.
      Type Parameters:
      N - The type of the number.
      Parameters:
      number - The number.
      Returns:
      The update expression.
    • logBaseN

      static UpdateExpression<Double> logBaseN(Double n)
      Creates an update expression evaluating the current value log base n.
      Parameters:
      n - The number.
      Returns:
      The update expression.
    • ln

      static UpdateExpression<Double> ln()
      Creates an update expression evaluating the natural logarithm of the current value.
      Returns:
      The update expression.
    • sqrt

      static UpdateExpression<Double> sqrt()
      Creates an update expression evaluating the square root of the current value.
      Returns:
      The update expression.
    • abs

      static UpdateExpression<Number> abs()
      Creates an update expression evaluating the absolute value of the current value.
      Returns:
      The update expression.
    • prepend

      static UpdateExpression<String> prepend(String prefix)
      Creates an update expression prepending a string to the current value.
      Parameters:
      prefix - The prefix to prepend to the current value.
      Returns:
      The update expression.
    • append

      static UpdateExpression<String> append(String suffix)
      Creates an update expression appending a string to the current value.
      Parameters:
      suffix - The suffix to append to the current value.
      Returns:
      The update expression.
    • trim

      static UpdateExpression<String> trim()
      Creates an update expression trimming the current value.
      Returns:
      The update expression.
    • trimTrailing

      static UpdateExpression<String> trimTrailing()
      Creates an update expression trimming trailing whitespace from the current value.
      Returns:
      The update expression.
    • trimLeading

      static UpdateExpression<String> trimLeading()
      Creates an update expression trimming leading whitespace from the current value.
      Returns:
      The update expression.
    • subString

      static UpdateExpression<String> subString(int startIndex)
      Creates an update expression evaluating a substring of the current value.
      Parameters:
      startIndex - The start index to substring from.
      Returns:
      The update expression.
    • subString

      static UpdateExpression<String> subString(int startIndex, int len)
      Creates an update expression evaluating a substring of the current value.
      Parameters:
      startIndex - The start index to substring from.
      len - The end index to substring from (exclusive).
      Returns:
      The update expression.