public class FluentLoader<E extends Entity<K>,K>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FluentLoader.ById<E extends Entity<K>,K> |
static class |
FluentLoader.ByIds<E extends Entity<K>,K> |
static class |
FluentLoader.ByQuery<E extends Entity<K>,K> |
Constructor and Description |
---|
FluentLoader(java.lang.Class<E> entityClass,
DataManager dataManager) |
FluentLoader(java.lang.Class<E> entityClass,
DataManager dataManager,
boolean transactional) |
Modifier and Type | Method and Description |
---|---|
FluentLoader<E,K> |
dynamicAttributes(boolean dynamicAttributes)
Sets loading of dynamic attributes.
|
FluentLoader.ById<E,K> |
id(K id)
Sets the entity identifier.
|
FluentLoader.ByIds<E,K> |
ids(java.util.Collection<K> ids)
Sets collection of entity identifiers.
|
FluentLoader.ByIds<E,K> |
ids(K... ids)
Sets array of entity identifiers.
|
java.util.List<E> |
list()
Loads a list of entities.
|
E |
one()
Loads a single instance.
|
java.util.Optional<E> |
optional()
Loads a single instance and wraps it in Optional.
|
FluentLoader.ByQuery<E,K> |
query(java.lang.String queryString)
Sets the query text.
|
FluentLoader.ByQuery<E,K> |
query(java.lang.String queryString,
java.lang.Object... parameters)
Sets the query with positional parameters (e.g.
|
FluentLoader<E,K> |
softDeletion(boolean softDeletion)
Sets soft deletion.
|
FluentLoader<E,K> |
view(java.util.function.Consumer<ViewBuilder> viewBuilderConfigurer)
Sets a view configured by the
ViewBuilder . |
FluentLoader<E,K> |
view(java.lang.String viewName)
Sets a view by name.
|
FluentLoader<E,K> |
view(View view)
Sets a view.
|
FluentLoader<E,K> |
viewProperties(java.lang.String... properties)
Sets a view containing the given properties.
|
public FluentLoader(java.lang.Class<E> entityClass, DataManager dataManager)
public FluentLoader(java.lang.Class<E> entityClass, DataManager dataManager, boolean transactional)
@CheckReturnValue public java.util.List<E> list()
@CheckReturnValue public java.util.Optional<E> optional()
@CheckReturnValue public E one()
java.lang.IllegalStateException
- if nothing was loadedpublic FluentLoader<E,K> view(View view)
public FluentLoader<E,K> view(java.lang.String viewName)
public FluentLoader<E,K> view(java.util.function.Consumer<ViewBuilder> viewBuilderConfigurer)
ViewBuilder
. For example:
dataManager.load(Pet.class) .id(petId) .view(viewBuilder -> viewBuilder.addAll( "name", "owner.name")) .one();
public FluentLoader<E,K> viewProperties(java.lang.String... properties)
dataManager.load(Pet.class) .id(petId) .viewProperties( "name", "owner.name", "owner.address.city") .one();
public FluentLoader<E,K> softDeletion(boolean softDeletion)
public FluentLoader<E,K> dynamicAttributes(boolean dynamicAttributes)
public FluentLoader.ById<E,K> id(K id)
@SafeVarargs public final FluentLoader.ByIds<E,K> ids(K... ids)
public FluentLoader.ByIds<E,K> ids(java.util.Collection<K> ids)
public FluentLoader.ByQuery<E,K> query(java.lang.String queryString)
public FluentLoader.ByQuery<E,K> query(java.lang.String queryString, java.lang.Object... parameters)
"e.name = ?1 and e.status = ?2"
).