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

org.dellroad.querystream.jpa.ExprStream 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.List;
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.TemporalType;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Order;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;
import javax.persistence.criteria.Subquery;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SingularAttribute;

/**
 * {@link SearchStream} containing items representable as {@link Expression}s.
 */
public interface ExprStream> extends SearchStream {

// Subqueries

    /**
     * Convert this instance into a subquery that can be used within an intermediate step of an outer query.
     *
     * @return criteria subquery object corresponding to this stream
     * @throws IllegalStateException if not invoked during a terminal operation on an outer query
     */
    Subquery asSubquery();

    /**
     * Convert this instance into an "exists" subquery that can be used within an intermediate step of an outer query.
     *
     * 

* Note: to perform the equivalent of an "exists" operation on the outermost query, use {@link #isEmpty}. * * @return boolean single-valued stream determining the existence of any items in this stream * @throws IllegalStateException if invoked on a stream which is not being used as a subquery * @see #isEmpty */ Predicate exists(); // Aggregation /** * Create value returning the number of instances in this stream. * *

* Warning: don't use in combination with {@code groupBy()}, because SQL's {@code COUNT()} returns a non-unique * result in grouped queries, or else a {@link javax.persistence.NonUniqueResultException} can result. * * @return single-valued stream counting instances in this stream */ LongValue count(); /** * Create value returning the number of distinct instances in this stream. * *

* Warning: don't use in combination with {@code groupBy()}, because SQL's {@code COUNT()} returns a non-unique * result in grouped queries, or else a {@link javax.persistence.NonUniqueResultException} can result. * * @return single-valued stream counting distinct instances in this stream */ LongValue countDistinct(); // Narrowing overrides (SearchStream) @Override ExprStream distinct(); @Override ExprStream orderBy(Ref> ref, boolean asc); @Override ExprStream orderBy(SingularAttribute attribute, boolean asc); @Override ExprStream orderBy(SingularAttribute attribute1, boolean asc1, SingularAttribute attribute2, boolean asc2); @Override ExprStream orderBy(SingularAttribute attribute1, boolean asc1, SingularAttribute attribute2, boolean asc2, SingularAttribute attribute3, boolean asc3); @Override ExprStream orderBy(Function> orderExprFunction, boolean asc); @Override ExprStream orderBy(Order... orders); @Override ExprStream orderByMulti(Function> orderListFunction); @Override ExprStream thenOrderBy(SingularAttribute attribute, boolean asc); @Override ExprStream thenOrderBy(Ref> ref, boolean asc); @Override ExprStream thenOrderBy(Order... orders); @Override ExprStream thenOrderBy(Function> orderExprFunction, boolean asc); @Override ExprStream groupBy(Ref> ref); @Override ExprStream groupBy(SingularAttribute attribute); @Override ExprStream groupBy(Function> groupFunction); @Override ExprStream groupByMulti(Function>> groupFunction); @Override ExprStream having(Function> havingFunction); @Override ExprValue findAny(); @Override ExprValue findFirst(); @Override ExprValue findSingle(); @Override ExprStream fetch(SingularAttribute attribute); @Override ExprStream fetch(SingularAttribute attribute, JoinType joinType); @Override ExprStream fetch(PluralAttribute attribute); @Override ExprStream fetch(PluralAttribute attribute, JoinType joinType); // Narrowing overrides (QueryStream) @Override ExprStream bind(Ref ref); @Override ExprStream peek(Consumer peeker); @Override > ExprStream bind(Ref ref, Function refFunction); @Override ExprStream addRoot(Ref> ref, Class type); @Override ExprStream filter(SingularAttribute attribute); @Override ExprStream filter(Function> predicateBuilder); @Override ExprStream limit(int maxSize); @Override ExprStream skip(int num); @Override ExprStream withFlushMode(FlushModeType flushMode); @Override ExprStream withLockMode(LockModeType lockMode); @Override ExprStream withHint(String name, Object value); @Override ExprStream withHints(Map hints); @Override ExprStream withParam(Parameter parameter, T value); @Override ExprStream withParam(Parameter parameter, Date value, TemporalType temporalType); @Override ExprStream withParam(Parameter parameter, Calendar value, TemporalType temporalType); @Override ExprStream withParams(Iterable> params); @Override ExprStream withLoadGraph(String name); @Override ExprStream withFetchGraph(String name); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy