Package io.jmix.core

Class FluentLoader<E>

java.lang.Object
io.jmix.core.FluentLoader<E>

@Component("core_FluentLoader") @Scope("prototype") public class FluentLoader<E> extends Object
  • Field Details

    • applicationContext

      @Autowired protected org.springframework.context.ApplicationContext applicationContext
  • Constructor Details

    • FluentLoader

      public FluentLoader(Class<E> entityClass)
  • Method Details

    • setDataManager

      public void setDataManager(UnconstrainedDataManager dataManager)
    • instantiateLoadContext

      protected LoadContext<E> instantiateLoadContext(MetaClass metaClass)
    • createFetchPlanBuilder

      protected void createFetchPlanBuilder()
    • id

      public FluentLoader.ById<E> id(Object id)
      Load by entity identifier.

      For example:

       Customer customer = dataManager.load(Customer.class)
                .id(someId)
                .one();
      
       Optional<Customer> customer = dataManager.load(Customer.class)
                .id(someId)
                .optional();
       
    • ids

      public FluentLoader.ByIds<E> ids(Object... ids)
      Load by array of entity identifiers.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
                .ids(id1, id2)
                .list();
       
      Entities in the result list have the same order as provided identifiers. If an instance from the list cannot be loaded for some reason, the whole operation fails with EntityAccessException.
    • ids

      public FluentLoader.ByIds<E> ids(Collection ids)
      Load by collection of entity identifiers.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
                .ids(idCollection)
                .list();
       
      Entities in the result list have the same order as provided identifiers. If an instance from the list cannot be loaded for some reason, the whole operation fails with EntityAccessException.
    • query

      public FluentLoader.ByQuery<E> query(String queryString)
      Load by query.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
            .query("select c from Customer c where c.name like :name")
            .parameter("name", "(?i)%doe%") // case-insensitive substring search
            .maxResults(100)
            .list();
       
      See Also:
    • query

      public FluentLoader.ByQuery<E> query(String queryString, Object... parameters)
      Load by query with positional parameters (e.g. "e.name = ?1 and e.status = ?2").

      Always use e as the entity alias.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
            .query("e.name like ?1", "(?i)%doe%") // case-insensitive substring search
            .maxResults(100)
            .list();
       
    • condition

      public FluentLoader.ByCondition<E> condition(Condition condition)
      Load by condition.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
            .condition(PropertyCondition.contains("name", "(?i)%doe%")) // case-insensitive substring search
            .maxResults(100)
            .list();
       
    • all

      public FluentLoader.ByCondition<E> all()
      Load all instances.

      For example:

       List<Customer> customers = dataManager.load(Customer.class)
            .all()
            .maxResults(100)
            .list();