Interface UpdateStream<X>

All Superinterfaces:
QueryConfigurer<jakarta.persistence.criteria.CriteriaUpdate<X>,X,jakarta.persistence.criteria.Root<X>>, QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>

public interface UpdateStream<X> extends QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
Builder for JPA criteria bulk update queries using a Stream-like API.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.dellroad.querystream.jpa.QueryStream

    QueryStream.Builder
  • Method Summary

    Modifier and Type
    Method
    Description
    bind(Ref<X,? super jakarta.persistence.criteria.Root<X>> ref)
    Bind an unbound reference to the items in this stream.
    <X2, S2 extends jakarta.persistence.criteria.Selection<X2>>
    UpdateStream<X>
    bind(Ref<X2,? super S2> ref, Function<? super jakarta.persistence.criteria.Root<X>,? extends S2> refFunction)
    Bind an unbound reference to the result of applying the given function to the items in this stream.
    filter(jakarta.persistence.metamodel.SingularAttribute<? super X,Boolean> attribute)
    Filter results using the specified boolean property.
    filter(Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<Boolean>> predicateBuilder)
    Filter results using the boolean expression produced by the given function.
    Get the QueryType of this instance.
    limit(int maxSize)
    Return this stream truncated to the specified maximum length.
    peek(Consumer<? super jakarta.persistence.criteria.Root<X>> peeker)
    Peek at the items in this stream.
    set(jakarta.persistence.criteria.Path<Y> path, jakarta.persistence.criteria.Expression<? extends Y> value)
    Set the property described by the specified Path to the value described by the specified expression.
    set(jakarta.persistence.criteria.Path<Y> path, Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder)
    Set the property described by the specified Path using the value expression returned by the given function.
    <Y, V extends Y>
    UpdateStream<X>
    set(jakarta.persistence.criteria.Path<Y> path, V value)
    Set the property described by the specified Path to the specified value.
    set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, jakarta.persistence.criteria.Expression<? extends Y> value)
    Set the property described by the specified attribute to the value described by the specified expression.
    set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder)
    Set the property described by the specified attribute using the value expression returned by the given function.
    <Y, V extends Y>
    UpdateStream<X>
    set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, V value)
    Set the property described by the specified attribute to the specified value.
    skip(int num)
    Return this stream with the specified number of initial elements skipped.
    int
    Build and execute a JPA query based on this instance.
    Configure a fetch graph for this query.
    withFlushMode(jakarta.persistence.FlushModeType flushMode)
    Set the FlushModeType associated with this query.
    withHint(String name, Object value)
    Associate a hint with this query.
    Associate hints with this query.
    Configure a load graph for this query.
    withLockMode(jakarta.persistence.LockModeType lockMode)
    Set the LockModeType associated with this query.
    withParam(jakarta.persistence.Parameter<Calendar> parameter, Calendar value, jakarta.persistence.TemporalType temporalType)
    Bind the value of a query parameter of type Calendar.
    withParam(jakarta.persistence.Parameter<Date> parameter, Date value, jakarta.persistence.TemporalType temporalType)
    Bind the value of a query parameter of type Date.
    withParam(jakarta.persistence.Parameter<T> parameter, T value)
    Bind the value of a query parameter.
    withParams(Iterable<? extends ParamBinding<?>> params)
    Associate parameter bindings with this query.

    Methods inherited from interface org.dellroad.querystream.jpa.QueryConfigurer

    configure

    Methods inherited from interface org.dellroad.querystream.jpa.QueryStream

    getEntityManager, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParams, toCriteriaQuery, toQuery
  • Method Details

    • update

      int update()
      Build and execute a JPA query based on this instance.

      Ultimately delegates to Query.executeUpdate() and can throw any exception thrown by that method.

      Returns:
      the number of entities updated
    • set

      <Y> UpdateStream<X> set(jakarta.persistence.criteria.Path<Y> path, jakarta.persistence.criteria.Expression<? extends Y> value)
      Set the property described by the specified Path to the value described by the specified expression.
      Type Parameters:
      Y - property type
      Parameters:
      path - the property to be set
      value - JPA expression for the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if path is null
      IllegalArgumentException - if value is null
    • set

      <Y, V extends Y> UpdateStream<X> set(jakarta.persistence.criteria.Path<Y> path, V value)
      Set the property described by the specified Path to the specified value.
      Type Parameters:
      Y - property type
      V - value type
      Parameters:
      path - the property to be set
      value - the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if path is null
    • set

      <Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, jakarta.persistence.criteria.Expression<? extends Y> value)
      Set the property described by the specified attribute to the value described by the specified expression.
      Type Parameters:
      Y - property type
      Parameters:
      attribute - entity attribute to be set
      value - JPA expression for the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if attribute is null
      IllegalArgumentException - if value is null
    • set

      <Y, V extends Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, V value)
      Set the property described by the specified attribute to the specified value.
      Type Parameters:
      Y - property type
      V - value type
      Parameters:
      attribute - entity attribute to be set
      value - the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if attribute is null
    • set

      <Y> UpdateStream<X> set(jakarta.persistence.criteria.Path<Y> path, Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder)
      Set the property described by the specified Path using the value expression returned by the given function.
      Type Parameters:
      Y - property type
      Parameters:
      path - the property to be set
      expressionBuilder - function returning a JPA expression for the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if path is null
      IllegalArgumentException - if expressionBuilder is null
    • set

      <Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X,Y> attribute, Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder)
      Set the property described by the specified attribute using the value expression returned by the given function.
      Type Parameters:
      Y - property type
      Parameters:
      attribute - entity attribute to be set
      expressionBuilder - function returning a JPA expression for the value to set
      Returns:
      new modified stream
      Throws:
      IllegalArgumentException - if attribute is null
      IllegalArgumentException - if expressionBuilder is null
    • getQueryType

      UpdateType<X> getQueryType()
      Description copied from interface: QueryStream
      Get the QueryType of this instance.
      Specified by:
      getQueryType in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Returns:
      associated QueryType
    • bind

      UpdateStream<X> bind(Ref<X,? super jakarta.persistence.criteria.Root<X>> ref)
      Description copied from interface: QueryStream
      Bind an unbound reference to the items in this stream.
      Specified by:
      bind in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      ref - unbound reference
      Returns:
      new stream that binds ref
    • bind

      <X2, S2 extends jakarta.persistence.criteria.Selection<X2>> UpdateStream<X> bind(Ref<X2,? super S2> ref, Function<? super jakarta.persistence.criteria.Root<X>,? extends S2> refFunction)
      Description copied from interface: QueryStream
      Bind an unbound reference to the result of applying the given function to the items in this stream.
      Specified by:
      bind in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Type Parameters:
      X2 - type of the bound value
      S2 - criteria type of the bound value
      Parameters:
      ref - unbound reference
      refFunction - function mapping this stream's Selection to the reference value
      Returns:
      new stream that binds ref
    • peek

      UpdateStream<X> peek(Consumer<? super jakarta.persistence.criteria.Root<X>> peeker)
      Description copied from interface: QueryStream
      Peek at the items in this stream.

      This is useful in cases where the selection can be modified, e.g., setting join ON conditions using Join.on().

      Specified by:
      peek in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      peeker - peeker into stream
      Returns:
      new stream that peeks into this stream
    • filter

      UpdateStream<X> filter(jakarta.persistence.metamodel.SingularAttribute<? super X,Boolean> attribute)
      Description copied from interface: QueryStream
      Filter results using the specified boolean property.

      Adds to any previously specified filters.

      Specified by:
      filter in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      attribute - boolean property
      Returns:
      new filtered stream
    • filter

      UpdateStream<X> filter(Function<? super jakarta.persistence.criteria.Root<X>,? extends jakarta.persistence.criteria.Expression<Boolean>> predicateBuilder)
      Description copied from interface: QueryStream
      Filter results using the boolean expression produced by the given function.

      Adds to any previously specified filters.

      Specified by:
      filter in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      predicateBuilder - function mapping this stream's item to a boolean Expression
      Returns:
      new filtered stream
    • limit

      UpdateStream<X> limit(int maxSize)
      Description copied from interface: QueryStream
      Return this stream truncated to the specified maximum length.

      Due to limitations in the JPA Criteria API, this method is not supported on subquery streams and in general must be specified last (after any filtering, sorting, grouping, joins, etc.).

      Specified by:
      limit in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      maxSize - maximum number of elements to return
      Returns:
      new truncated stream
    • skip

      UpdateStream<X> skip(int num)
      Description copied from interface: QueryStream
      Return this stream with the specified number of initial elements skipped.

      Due to limitations in the JPA Criteria API, this method is not supported on subquery streams and in general must be specified last (after any filtering, sorting, grouping, joins, etc.).

      Specified by:
      skip in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      num - number of elements to skip
      Returns:
      new elided stream
    • withFlushMode

      UpdateStream<X> withFlushMode(jakarta.persistence.FlushModeType flushMode)
      Description copied from interface: QueryStream
      Set the FlushModeType associated with this query.
      Specified by:
      withFlushMode in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      flushMode - new flush mode
      Returns:
      new stream with the specified flush mode configured
      See Also:
      • Query.setFlushMode(jakarta.persistence.FlushModeType)
    • withLockMode

      UpdateStream<X> withLockMode(jakarta.persistence.LockModeType lockMode)
      Description copied from interface: QueryStream
      Set the LockModeType associated with this query.
      Specified by:
      withLockMode in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      lockMode - new lock mode
      Returns:
      new stream with the specified lock mode configured
      See Also:
      • Query.setLockMode(jakarta.persistence.LockModeType)
    • withHint

      UpdateStream<X> withHint(String name, Object value)
      Description copied from interface: QueryStream
      Associate a hint with this query.
      Specified by:
      withHint in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      name - name of hint
      value - value of hint
      Returns:
      new stream with the specified hint configured
      See Also:
      • Query.setHint(java.lang.String, java.lang.Object)
    • withHints

      UpdateStream<X> withHints(Map<String,Object> hints)
      Description copied from interface: QueryStream
      Associate hints with this query.
      Specified by:
      withHints in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      hints - hints to add
      Returns:
      new stream with the specified hints added
      See Also:
      • Query.setHint(java.lang.String, java.lang.Object)
    • withParam

      <T> UpdateStream<X> withParam(jakarta.persistence.Parameter<T> parameter, T value)
      Description copied from interface: QueryStream
      Bind the value of a query parameter.

      Replaces any previous binding of the same parameter.

      Specified by:
      withParam in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Type Parameters:
      T - parameter value type
      Parameters:
      parameter - the parameter to set
      value - parameter value
      Returns:
      new stream with the specified parameter value set
      See Also:
      • Query.setParameter(Parameter, Object)
    • withParam

      UpdateStream<X> withParam(jakarta.persistence.Parameter<Date> parameter, Date value, jakarta.persistence.TemporalType temporalType)
      Description copied from interface: QueryStream
      Bind the value of a query parameter of type Date.

      Replaces any previous binding of the same parameter.

      Specified by:
      withParam in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      parameter - the parameter to set
      value - parameter value
      temporalType - temporal type for value
      Returns:
      new stream with the specified parameter value set
      See Also:
      • Query.setParameter(Parameter, Date, TemporalType)
    • withParam

      UpdateStream<X> withParam(jakarta.persistence.Parameter<Calendar> parameter, Calendar value, jakarta.persistence.TemporalType temporalType)
      Description copied from interface: QueryStream
      Bind the value of a query parameter of type Calendar.

      Replaces any previous binding of the same parameter.

      Specified by:
      withParam in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      parameter - the parameter to set
      value - parameter value
      temporalType - temporal type for value
      Returns:
      new stream with the specified parameter value set
      See Also:
      • Query.setParameter(Parameter, Calendar, TemporalType)
    • withParams

      UpdateStream<X> withParams(Iterable<? extends ParamBinding<?>> params)
      Description copied from interface: QueryStream
      Associate parameter bindings with this query.

      Replaces any previous bindings of the same parameters.

      Specified by:
      withParams in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      params - bindings to add
      Returns:
      new stream with the specified parameter bindings added
      See Also:
      • Query.setParameter(Parameter, Object)
    • withLoadGraph

      UpdateStream<X> withLoadGraph(String name)
      Description copied from interface: QueryStream
      Configure a load graph for this query.

      Equivalent to withHint("jakarta.persistence.loadgraph", name).

      Specified by:
      withLoadGraph in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      name - name of load graph
      Returns:
      new stream with the specified load graph configured
    • withFetchGraph

      UpdateStream<X> withFetchGraph(String name)
      Description copied from interface: QueryStream
      Configure a fetch graph for this query.

      Equivalent to withHint("jakarta.persistence.fetchgraph", name).

      Specified by:
      withFetchGraph in interface QueryStream<X,jakarta.persistence.criteria.Root<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.criteria.CriteriaUpdate<X>,jakarta.persistence.Query>
      Parameters:
      name - name of fetch graph
      Returns:
      new stream with the specified fetch graph configured