All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dellroad.querystream.jpa.UpdateStream Maven / Gradle / Ivy


/*
 * Copyright (C) 2018 Archie L. Cobbs. All rights reserved.
 */

package org.dellroad.querystream.jpa;

import java.util.Calendar;
import java.util.Date;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;

import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Parameter;
import javax.persistence.Query;
import javax.persistence.TemporalType;
import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;
import javax.persistence.metamodel.SingularAttribute;

import org.dellroad.querystream.jpa.querytype.UpdateType;

/**
 * Builder for JPA criteria bulk update queries using a {@link java.util.stream.Stream}-like API.
 */
public interface UpdateStream extends QueryStream, CriteriaUpdate, CriteriaUpdate, Query> {

    /**
     * Build and execute a JPA query based on this instance.
     *
     * 

* Ultimately delegates to {@link Query#executeUpdate} and can throw any exception thrown by that method. * * @return the number of entities updated */ int update(); // Setters /** * Set the property described by the specified {@link Path} to the value described by the specified expression. * * @param path the property to be set * @param value JPA expression for the value to set * @param property type * @return new modified stream * @throws IllegalArgumentException if {@code path} is null * @throws IllegalArgumentException if {@code value} is null */ UpdateStream set(Path path, Expression value); /** * Set the property described by the specified {@link Path} to the specified value. * * @param path the property to be set * @param value the value to set * @param property type * @param value type * @return new modified stream * @throws IllegalArgumentException if {@code path} is null */ UpdateStream set(Path path, V value); /** * Set the property described by the specified attribute to the value described by the specified expression. * * @param attribute entity attribute to be set * @param value JPA expression for the value to set * @param property type * @return new modified stream * @throws IllegalArgumentException if {@code attribute} is null * @throws IllegalArgumentException if {@code value} is null */ UpdateStream set(SingularAttribute attribute, Expression value); /** * Set the property described by the specified attribute to the specified value. * * @param attribute entity attribute to be set * @param value the value to set * @param property type * @param value type * @return new modified stream * @throws IllegalArgumentException if {@code attribute} is null */ UpdateStream set(SingularAttribute attribute, V value); /** * Set the property described by the specified {@link Path} using the value expression returned by the given function. * * @param path the property to be set * @param expressionBuilder function returning a JPA expression for the value to set * @param property type * @return new modified stream * @throws IllegalArgumentException if {@code path} is null * @throws IllegalArgumentException if {@code expressionBuilder} is null */ UpdateStream set(Path path, Function, ? extends Expression> expressionBuilder); /** * Set the property described by the specified attribute using the value expression returned by the given function. * * @param attribute entity attribute to be set * @param expressionBuilder function returning a JPA expression for the value to set * @param property type * @return new modified stream * @throws IllegalArgumentException if {@code attribute} is null * @throws IllegalArgumentException if {@code expressionBuilder} is null */ UpdateStream set(SingularAttribute attribute, Function, ? extends Expression> expressionBuilder); // Narrowing overrides @Override UpdateType getQueryType(); @Override UpdateStream bind(Ref> ref); @Override > UpdateStream bind(Ref ref, Function, ? extends S2> refFunction); @Override UpdateStream peek(Consumer> peeker); @Override UpdateStream filter(SingularAttribute attribute); @Override UpdateStream filter(Function, ? extends Expression> predicateBuilder); @Override UpdateStream limit(int maxSize); @Override UpdateStream skip(int num); @Override UpdateStream withFlushMode(FlushModeType flushMode); @Override UpdateStream withLockMode(LockModeType lockMode); @Override UpdateStream withHint(String name, Object value); @Override UpdateStream withHints(Map hints); @Override UpdateStream withParam(Parameter parameter, T value); @Override UpdateStream withParam(Parameter parameter, Date value, TemporalType temporalType); @Override UpdateStream withParam(Parameter parameter, Calendar value, TemporalType temporalType); @Override UpdateStream withParams(Iterable> params); @Override UpdateStream withLoadGraph(String name); @Override UpdateStream withFetchGraph(String name); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy