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
Modifier and TypeClassDescriptionstatic class
Class that defines a query to be executed for data loading. -
Field Summary
Modifier and TypeFieldDescriptionprotected List<AccessConstraint<?>>
protected FetchPlan
protected Map<String,
Serializable> protected Object
protected boolean
protected boolean
protected javax.persistence.LockModeType
protected MetaClass
protected List<LoadContext.Query>
protected LoadContext.Query
protected int
-
Constructor Summary
-
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()
javax.persistence.LockModeType
Allows to execute query on a previous query result.getQuery()
int
boolean
boolean
setAccessConstraints
(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.void
setLockMode
(javax.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 javax.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:
setQueryString
in interfaceDataLoadContext
- Parameters:
queryString
- query string. Only named parameters are supported.- Returns:
- query definition object
-
setLockMode
public void setLockMode(javax.persistence.LockModeType lockMode) - Specified by:
setLockMode
in interfaceDataLoadContext
- Parameters:
lockMode
- lock mode to be used when executing query
-
getLockMode
@Nullable public javax.persistence.LockModeType getLockMode()- Specified by:
getLockMode
in 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
-