Package io.jmix.core

Class LoadContext<E>

java.lang.Object
io.jmix.core.LoadContext<E>
All Implemented Interfaces:
DataLoadContext, Serializable

public class LoadContext<E> extends Object implements 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:
  • Field Details

  • Constructor Details

    • LoadContext

      public LoadContext(MetaClass metaClass)
      Parameters:
      metaClass - metaclass of the loaded entities
    • LoadContext

      protected LoadContext()
  • Method Details

    • getEntityMetaClass

      public MetaClass getEntityMetaClass()
      Returns:
      metaclass of the loaded entities
    • getQuery

      @Nullable public LoadContext.Query getQuery()
      Returns:
      query definition
    • setQuery

      public LoadContext<E> setQuery(LoadContext.Query query)
      Parameters:
      query - query definition
      Returns:
      this instance for chaining
    • setQueryString

      public LoadContext.Query setQueryString(String queryString)
      Specified by:
      setQueryString in interface DataLoadContext
      Parameters:
      queryString - JPQL query string. Only named parameters are supported.
      Returns:
      query definition object
    • getFetchPlan

      @Nullable public FetchPlan getFetchPlan()
      Returns:
      fetchPlan that is used for loading entities
    • setFetchPlan

      public LoadContext<E> setFetchPlan(FetchPlan fetchPlan)
      Parameters:
      fetchPlan - fetchPlan that is used for loading entities
      Returns:
      this instance for chaining
    • getId

      @Nullable public Object getId()
      Returns:
      id of an entity to be loaded
    • setId

      public LoadContext<E> setId(Object id)
      Parameters:
      id - id of an entity to be loaded
      Returns:
      this instance for chaining
    • getIds

      public List<?> getIds()
      Returns:
      identifiers of entities to be loaded
    • setIds

      public LoadContext<E> setIds(Collection<?> ids)
      Parameters:
      ids - identifiers of entities to be loaded
      Returns:
      this instance for chaining
    • getPreviousQueries

      public List<LoadContext.Query> 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

      public LoadContext<E> setQueryKey(int queryKey)
      Parameters:
      queryKey - key of the current stack of sequential queries, which is unique for the current user session
    • getHints

      public Map<String,Object> getHints()
      Returns:
      custom hints which are used by the query
    • setHint

      public LoadContext<E> setHint(String hintName, Serializable value)
      Sets custom hint that should be used by the query.
    • setHints

      public LoadContext<E> setHints(Map<String,Serializable> hints)
      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 to DataManager.

    • setLoadPartialEntities

      public LoadContext<E> setLoadPartialEntities(boolean loadPartialEntities)
      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 to DataManager.

    • getAccessConstraints

      public List<AccessConstraint<?>> 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

      public LoadContext<E> setJoinTransaction(boolean joinTransaction)
      Sets whether to join existing transaction or always start a new one.
    • copy

      public LoadContext<?> copy()
      Creates a copy of this LoadContext instance.
    • toString

      public String toString()
      Overrides:
      toString in class Object