Package io.jmix.core

Class ValueLoadContext

java.lang.Object
io.jmix.core.ValueLoadContext
All Implemented Interfaces:
DataLoadContext, Serializable

public class ValueLoadContext extends Object implements DataLoadContext, Serializable
Class that defines parameters for loading values from the database via UnconstrainedDataManager.loadValues(ValueLoadContext).

Typical usage:

 ValueLoadContext context = ValueLoadContext.create()
      .setQuery(ValueLoadContext.createQuery("select e.id, e.name from sample$Customer e where e.grade = :grade")
          .setParameter("grade", 1))
      .addProperty("id")
      .addProperty("name");
 
See Also:
  • Field Details

    • storeName

      protected String storeName
    • query

      protected ValueLoadContext.Query query
    • softDeletion

      protected boolean softDeletion
    • idName

      protected String idName
    • properties

      protected List<String> properties
    • accessConstraints

      protected List<AccessConstraint<?>> accessConstraints
    • hints

      protected Map<String,Serializable> hints
    • joinTransaction

      protected boolean joinTransaction
    • lockMode

      protected javax.persistence.LockModeType lockMode
  • Constructor Details

    • ValueLoadContext

      public ValueLoadContext()
  • Method Details

    • create

      public static ValueLoadContext create()
      Creates an instance of ValueLoadContext
    • createQuery

      public static ValueLoadContext.Query createQuery(String queryString)
      Creates an instance of ValueLoadContext query
    • setQueryString

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

      public void setLockMode(javax.persistence.LockModeType lockMode)
      Specified by:
      setLockMode in interface DataLoadContext
      Parameters:
      lockMode - lock mode to be used when executing query
    • getLockMode

      @Nullable public javax.persistence.LockModeType getLockMode()
      Specified by:
      getLockMode in interface DataLoadContext
      Returns:
      lock mode to be used when executing query
    • getStoreName

      public String getStoreName()
      Returns:
      data store name if set by setStoreName(String)
    • setStoreName

      public ValueLoadContext setStoreName(String storeName)
      Sets a data store name if it is different from the main database.
      Returns:
      this instance for chaining
    • setQuery

      public ValueLoadContext setQuery(ValueLoadContext.Query query)
      Sets query instance
      Returns:
      this instance for chaining
    • getQuery

      public ValueLoadContext.Query getQuery()
      Returns:
      query instance
    • getHints

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

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

      public ValueLoadContext setHints(Map<String,Serializable> hints)
      Sets custom hints that should be used by the query.
    • getIdName

      public String getIdName()
      Returns:
      name of property that represents an identifier of the returned KeyValueEntity, if set by setIdName(String)
    • setIdName

      public void setIdName(String idName)
      Sets name of the property that represents an identifier of the returned KeyValueEntity.
    • addProperty

      public ValueLoadContext addProperty(String name)
      Adds a key of a returned key-value pair. The sequence of adding properties must conform to the sequence of result fields in the query "select" clause.

      For example, if the query is select e.id, e.name from sample$Customer and you executed context.addProperty("customerId").addProperty("customerName"), the returned KeyValueEntity will contain customer identifiers in "customerId" property and names in "customerName" property.

      Returns:
      this instance for chaining
    • setProperties

      public ValueLoadContext setProperties(List<String> properties)
      The same as invoking addProperty(String) multiple times.
      Returns:
      this instance for chaining
    • getProperties

      public List<String> getProperties()
      Returns:
      the list of properties added by addProperty(String)
    • getAccessConstraints

      public List<AccessConstraint<?>> getAccessConstraints()
    • setAccessConstraints

      public ValueLoadContext setAccessConstraints(List<AccessConstraint<?>> accessConstraints)
    • isJoinTransaction

      public boolean isJoinTransaction()
    • setJoinTransaction

      public ValueLoadContext setJoinTransaction(boolean joinTransaction)
    • toString

      public String toString()
      Overrides:
      toString in class Object