Package io.jmix.core
Class LoadContext<E>
java.lang.Object
io.jmix.core.LoadContext<E>
- All Implemented Interfaces:
DataLoadContext,Serializable
Class that defines parameters for loading entities from the database via
DataManager.
Typical usage:
LoadContext<User> context = new LoadContext(userMetaClass).setQuery(
new LoadContext.Query("select u from sec$User u where u.login like :login")
.setParameter("login", "a%")
.setMaxResults(10))
.setFetchPlan("user.browse");
List<User> users = dataManager.loadList(context);
Instead of using this class directly, consider fluent interface with the entry point in UnconstrainedDataManager.load(Class).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that defines a query to be executed for data loading. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<AccessConstraint<?>>protected FetchPlanprotected Map<String,Serializable> protected Objectprotected booleanprotected booleanprotected jakarta.persistence.LockModeTypeprotected MetaClassprotected List<LoadContext.Query>protected LoadContext.Queryprotected int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLoadContext<?>copy()Creates a copy of this LoadContext instance.List<AccessConstraint<?>>Returns directly accessible list of access constraints.getHints()getId()List<?>getIds()jakarta.persistence.LockModeTypeAllows to execute query on a previous query result.getQuery()intbooleanbooleansetAccessConstraints(Collection<AccessConstraint<?>> accessConstraints) Sets list of access constraints.setFetchPlan(FetchPlan fetchPlan) setHint(String hintName, Serializable value) Sets custom hint that should be used by the query.setHints(Map<String, Serializable> hints) Sets custom hints that should be used by the query.setIds(Collection<?> ids) setJoinTransaction(boolean joinTransaction) Sets whether to join existing transaction or always start a new one.setLoadPartialEntities(boolean loadPartialEntities) Whether to load partial entities.voidsetLockMode(jakarta.persistence.LockModeType lockMode) setQuery(LoadContext.Query query) setQueryKey(int queryKey) setQueryString(String queryString) toString()
-
Field Details
-
metaClass
-
query
-
fetchPlan
-
id
-
idList
-
prevQueries
-
accessConstraints
-
queryKey
protected int queryKey -
loadPartialEntities
protected boolean loadPartialEntities -
joinTransaction
protected boolean joinTransaction -
hints
-
lockMode
protected jakarta.persistence.LockModeType lockMode
-
-
Constructor Details
-
LoadContext
- Parameters:
metaClass- metaclass of the loaded entities
-
LoadContext
protected LoadContext()
-
-
Method Details
-
getEntityMetaClass
- Returns:
- metaclass of the loaded entities
-
getQuery
- Returns:
- query definition
-
setQuery
- Parameters:
query- query definition- Returns:
- this instance for chaining
-
setQueryString
- Specified by:
setQueryStringin interfaceDataLoadContext- Parameters:
queryString- query string. Only named parameters are supported.- Returns:
- query definition object
-
setLockMode
public void setLockMode(jakarta.persistence.LockModeType lockMode) - Specified by:
setLockModein interfaceDataLoadContext- Parameters:
lockMode- lock mode to be used when executing query
-
getLockMode
@Nullable public jakarta.persistence.LockModeType getLockMode()- Specified by:
getLockModein interfaceDataLoadContext- Returns:
- lock mode to be used when executing query
-
getFetchPlan
- Returns:
- fetchPlan that is used for loading entities
-
setFetchPlan
- Parameters:
fetchPlan- fetchPlan that is used for loading entities- Returns:
- this instance for chaining
-
getId
- Returns:
- id of an entity to be loaded
-
setId
- Parameters:
id- id of an entity to be loaded- Returns:
- this instance for chaining
-
getIds
- Returns:
- identifiers of entities to be loaded
-
setIds
- Parameters:
ids- identifiers of entities to be loaded- Returns:
- this instance for chaining
-
getPreviousQueries
Allows to execute query on a previous query result.- Returns:
- editable list of previous queries
-
getQueryKey
public int getQueryKey()- Returns:
- key of the current stack of sequential queries, which is unique for the current user session
-
setQueryKey
- Parameters:
queryKey- key of the current stack of sequential queries, which is unique for the current user session
-
getHints
- Returns:
- custom hints which are used by the query
-
setHint
Sets custom hint that should be used by the query. -
setHints
Sets custom hints that should be used by the query. -
isLoadPartialEntities
public boolean isLoadPartialEntities()- Returns:
- whether to load partial entities. When true (which is by default), some local attributes can be unfetched
according to
setFetchPlan(FetchPlan).The state of
FetchPlan.loadPartialEntities()is ignored when the fetchPlan is passed toDataManager.
-
setLoadPartialEntities
Whether to load partial entities. When true (which is by default), some local attributes can be unfetched according tosetFetchPlan(FetchPlan).The state of
FetchPlan.loadPartialEntities()is ignored when the fetchPlan is passed toDataManager. -
getAccessConstraints
Returns directly accessible list of access constraints. -
setAccessConstraints
public LoadContext<E> setAccessConstraints(@Nullable Collection<AccessConstraint<?>> accessConstraints) Sets list of access constraints. -
isJoinTransaction
public boolean isJoinTransaction()- Returns:
- whether to join existing transaction or always start a new one
-
setJoinTransaction
Sets whether to join existing transaction or always start a new one. -
copy
Creates a copy of this LoadContext instance. -
toString
-