Interface StreamConfiguration<T>
- Type Parameters:
T- the entity type
Instances are guaranteed to be immutable and therefore inherently thread-safe.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceJoinConfiguration instances are used to configure Stream joins. -
Method Summary
Modifier and TypeMethodDescriptionReturns the entity class that is to appear in a future Stream.hints()Returns the map with the query hints that will be configured in a future Stream.default StreamConfiguration<T>Creates and returns a new StreamConfiguration configured with the providedfieldso that it will be eagerly joined when producing elements in the future Stream usingJoinType.LEFT.Creates and returns a new StreamConfiguration configured with the providedfieldso that it will be eagerly joined when producing elements in the future Stream using the providedjoinType.joins()Returns the fields that shall be joined in a future stream.static <T> StreamConfiguration<T>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 orOptional.empty()if no projection should be used.Add a query hint.
-
Method Details
-
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
Set<StreamConfiguration.JoinConfiguration<T>> 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
Creates and returns a new StreamConfiguration configured with the providedfieldso that it will be eagerly joined when producing elements in the future Stream usingJoinType.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
fieldso that it will be eagerly joined when producing elements in the future Stream usingJoinType.LEFT
-
joining
Creates and returns a new StreamConfiguration configured with the providedfieldso that it will be eagerly joined when producing elements in the future Stream using the providedjoinType.This prevents the N+1 problem if the field is accessed in elements in the future Stream.
- Parameters:
field- to joinjoinType- type of join, e.g. left join- Returns:
- a new StreamConfiguration configured with
the provided
fieldso that it will be eagerly joined when producing elements in the future Stream using the providedjoinType
-
selections
Optional<Projection<T>> selections()Returns the projected columns to use when creating entities orOptional.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
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 idandString name(and potentially many other columns) and the columnsidandnameare 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
projectionso that it will use the projected columns to initialize when creating initial entities in a future stream
-
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
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 hintvalue- value for the property or hint.- Returns:
- a new StreamConfiguration configured with
the provided
hintNameand itsvalue
-
of
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
-