Interface JmixDataRepository<T,ID>

Type Parameters:
T - the domain type the repository manages
ID - the type of the id of the entity the repository manages
All Superinterfaces:
org.springframework.data.repository.CrudRepository<T,ID>, org.springframework.data.repository.PagingAndSortingRepository<T,ID>, org.springframework.data.repository.Repository<T,ID>
All Known Implementing Classes:
JmixDataRepositoryImpl

@NoRepositoryBean public interface JmixDataRepository<T,ID> extends org.springframework.data.repository.PagingAndSortingRepository<T,ID>, org.springframework.data.repository.CrudRepository<T,ID>
Central Jmix data repository interface.

Extends functionality of PagingAndSortingRepository by adding FetchPlan parameters to common methods and providing other Jmix-specific methods

See Also:
  • PagingAndSortingRepository
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the number of entities satisfying context available.
    Instantiate an entity.
    findAll(FetchPlan fetchPlan)
    Returns all instances of the type T loaded according to fetchPlan
    Returns all instances of the type T loaded by context
    findAll(Iterable<ID> ids, FetchPlan fetchPlan)
    Returns all instances of the type T with the given IDs loaded according to fetchPlan
    org.springframework.data.domain.Page<T>
    findAll(org.springframework.data.domain.Pageable pageable, FetchPlan fetchPlan)
    Returns a Page of entities meeting the paging restriction provided in the Pageable object.
    org.springframework.data.domain.Page<T>
    findAll(org.springframework.data.domain.Pageable pageable, JmixDataRepositoryContext jmixContext)
    Returns a Page of entities meeting the paging restriction provided in the Pageable object.
    findAll(org.springframework.data.domain.Sort sort, FetchPlan fetchPlan)
    Returns all entities sorted by the given options and loaded by specified FetchPlan.
    findById(ID id, FetchPlan fetchPlan)
    Loads an entity by its id according to fetchPlan
    getById(ID id)
    Loads an entity by its id
    getById(ID id, FetchPlan fetchPlan)
    Loads an entity by its id according to fetchPlan
     
    <S extends T>
    S
    save(S entity, FetchPlan fetchPlan)
    Saves the entity and returns saved instance loaded with specified fetchPlan.

    Methods inherited from interface org.springframework.data.repository.CrudRepository

    count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll

    Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

    findAll, findAll
  • Method Details

    • create

      T create()
      Instantiate an entity. Invokes Metadata.create(Class)
      Returns:
      new instance of <T>.
    • findById

      Optional<T> findById(ID id, FetchPlan fetchPlan)
      Loads an entity by its id according to fetchPlan
      Parameters:
      id - must not be null.
      Returns:
      the entity with the given id or Optional#empty() if none found.
    • getById

      T getById(ID id, @Nullable FetchPlan fetchPlan)
      Loads an entity by its id according to fetchPlan
      Parameters:
      id - must not be null.
      Returns:
      the entity with the given id
      Throws:
      NoResultException - if nothing was loaded
    • getById

      T getById(ID id)
      Loads an entity by its id
      Parameters:
      id - must not be null.
      Returns:
      the entity with the given id
      Throws:
      NoResultException - if nothing was loaded
    • findAll

      Iterable<T> findAll(FetchPlan fetchPlan)
      Returns all instances of the type T loaded according to fetchPlan
      Returns:
      all entities
    • findAll

      Returns all instances of the type T loaded by context
      Returns:
      entities by context
      See Also:
    • findAll

      Iterable<T> findAll(Iterable<ID> ids, @Nullable FetchPlan fetchPlan)
      Returns all instances of the type T with the given IDs loaded according to fetchPlan

      If some or all ids are not found, no entities are returned for these IDs.

      Parameters:
      fetchPlan - defines entity graph to load. FetchPlan.BASE will be used instead in case of null.
      ids - must not be null nor contain any null values.
      Returns:
      guaranteed to be not null. The size can be equal or less than the number of given ids.
      Throws:
      IllegalArgumentException - in case the given ids or one of its items is null.
    • findAll

      Iterable<T> findAll(org.springframework.data.domain.Sort sort, @Nullable FetchPlan fetchPlan)
      Returns all entities sorted by the given options and loaded by specified FetchPlan.
      Parameters:
      fetchPlan - to load entity. FetchPlan.BASE will be used if fetchPlan == null
      Returns:
      all entities sorted by the given options
    • findAll

      org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable, @Nullable FetchPlan fetchPlan)
      Returns a Page of entities meeting the paging restriction provided in the Pageable object. Entities will be loaded according to passed fetchPlan
      Parameters:
      fetchPlan - to load entities. FetchPlan.BASE will be used if fetchPlan == null
      Returns:
      a page of entities
    • findAll

      org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable, JmixDataRepositoryContext jmixContext)
      Returns a Page of entities meeting the paging restriction provided in the Pageable object. Entities will be loaded according to passed params
      Parameters:
      jmixContext - JmixDataRepositoryContext to load entities.
      Returns:
      a page of entities
    • count

      long count(JmixDataRepositoryContext context)
      Returns the number of entities satisfying context available.
      Returns:
      the number of entities satisfying context.
    • save

      <S extends T> S save(S entity, FetchPlan fetchPlan)
      Saves the entity and returns saved instance loaded with specified fetchPlan.
      Parameters:
      entity - entity to save. Must not be null
      fetchPlan - FetchPlan to reload saved entity with. Must be applicable to entity
      Throws:
      IllegalArgumentException - if fetchPlan is not applicable to entity
    • getDataManager

      DataManager getDataManager()
      Returns:
      DataManager to use in default methods.