Interface StreamConfiguration<T>

Type Parameters:
T - the entity type

public interface StreamConfiguration<T>
StreamConfiguration instances are used to specify certain properties of a Stream.

Instances are guaranteed to be immutable and therefore inherently thread-safe.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    JoinConfiguration instances are used to configure Stream joins.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the entity class that is to appear in a future Stream.
    Returns the map with the query hints that will be configured in a future Stream.
    joining(Field<T> field)
    Creates and returns a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using JoinType.LEFT.
    joining(Field<T> field, jakarta.persistence.criteria.JoinType joinType)
    Creates and returns a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using the provided joinType.
    Returns the fields that shall be joined in a future stream.
    static <T> StreamConfiguration<T>
    of(Class<T> entityClass)
    Creates and returns a new StreamConfiguration that can be used to configure streams.
    selecting(Projection<T> projection)
    Selects the projected columns to initialize when creating initial entities in a future stream.
    Returns the projected columns to use when creating entities or Optional.empty() if no projection should be used.
    withHint(String hintName, Object value)
    Add a query hint.
  • Method Details

    • entityClass

      Class<T> entityClass()
      Returns the entity class that is to appear in a future Stream.
      Returns:
      the entity class that is to appear in a future Stream
    • joins

      Returns the fields that shall be joined in a future stream.

      Joining fields prevents N + 1 select problems in cases fields in the Set are to be used by stream consumers.

      Returns:
      the fields that shall be joined in a future stream
    • joining

      default StreamConfiguration<T> joining(Field<T> field)
      Creates and returns a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using JoinType.LEFT.

      This prevents the N+1 problem if the field is accessed in elements in the future Stream.

      Parameters:
      field - to join
      Returns:
      a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using JoinType.LEFT
    • joining

      StreamConfiguration<T> joining(Field<T> field, jakarta.persistence.criteria.JoinType joinType)
      Creates and returns a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using the provided joinType.

      This prevents the N+1 problem if the field is accessed in elements in the future Stream.

      Parameters:
      field - to join
      joinType - type of join, e.g. left join
      Returns:
      a new StreamConfiguration configured with the provided field so that it will be eagerly joined when producing elements in the future Stream using the provided joinType
    • selections

      Optional<Projection<T>> selections()
      Returns the projected columns to use when creating entities or Optional.empty() if no projection should be used.

      A corresponding entity constructor must exist.

      Returns:
      the projected columns to use when creating entities or Optional.empty() if no projection should be used
    • selecting

      StreamConfiguration<T> selecting(Projection<T> projection)
      Selects the projected columns to initialize when creating initial entities in a future stream.

      If this method is never called, all columns will be selected.

      Un-selected columns will be set to their default values (e.g. null or 0)

      A corresponding entity constructor must exist. For example, if a Person with columns int id and String name (and potentially many other columns) and the columns id and name are used for projection, then the entity Person must have a constructor:

      
           public Person(int id, String name) {
               setId(id);
               setName(name);
           }
       
      Parameters:
      projection - the projection to use
      Returns:
      a new StreamConfiguration configured with the provided projection so that it will use the projected columns to initialize when creating initial entities in a future stream
    • hints

      Map<String,Object> hints()
      Returns the map with the query hints that will be configured in a future Stream.
      Returns:
      the map containing all the query hints
    • withHint

      StreamConfiguration<T> withHint(String hintName, Object value)
      Add a query hint.

      This method is useful when you need to customize how a query will be executed by the underlying persistence provider.

      Parameters:
      hintName - name of the property or hint
      value - value for the property or hint.
      Returns:
      a new StreamConfiguration configured with the provided hintName and its value
    • of

      static <T> StreamConfiguration<T> of(Class<T> entityClass)
      Creates and returns a new StreamConfiguration that can be used to configure streams.

      The method guarantees that the instances (and subsequent derived instances) are immutable. The method further guarantees that any object obtained from instances (or subsequent derived instances) are immutable or unmodifiable.

      Type Parameters:
      T - the type of the stream elements
      Parameters:
      entityClass - a class token for an entity class (annotated with @Entity)
      Returns:
      a new JPAStreamerBuilder