com.vaadin.hilla.crud.

Class ListRepositoryService<T,ID,R extends org.springframework.data.repository.CrudRepository<T,ID> & org.springframework.data.jpa.repository.JpaSpecificationExecutor<T>>

java.lang.Object
com.vaadin.hilla.crud.ListRepositoryService<T,ID,R>

All Implemented Interfaces:

CountService, GetService<T,ID>, ListService<T>

Direct Known Subclasses:

CrudRepositoryService

public class ListRepositoryService<T,ID,R extends org.springframework.data.repository.CrudRepository<T,ID> & org.springframework.data.jpa.repository.JpaSpecificationExecutor<T>> extends Object implements ListService<T>, GetService<T,ID>, CountService

A browser-callable service that delegates list operations to a JPA repository.

  • Constructor Details

    • ListRepositoryService

      public ListRepositoryService()
    • ListRepositoryService

      public ListRepositoryService(R repository)

      Creates the service using the given repository.

      Parameters:

      repository - the JPA repository

  • Method Details

    • getRepository

      protected R getRepository()

      Accessor for the repository instance.

      Returns:

      the repository instance

    • list

      public List<T> list(org.springframework.data.domain.Pageable pageable, @Nullable Filter filter)

      Description copied from interface: ListService

      Lists objects of the given type using the paging, sorting and filtering options provided in the parameters.

      Specified by:

      list in interface ListService<T>

      Parameters:

      pageable - contains information about paging and sorting

      filter - the filter to apply or null to not filter

      Returns:

      a list of objects or an empty list if no objects were found

    • get

      public Optional<T> get(ID id)

      Description copied from interface: GetService

      Gets the object with the given id.

      Specified by:

      get in interface GetService<T,ID>

      Parameters:

      id - the id of the object

      Returns:

      the object, or an empty optional if no object with the given id

    • exists

      public boolean exists(ID id)

      Description copied from interface: GetService

      Checks if an object with the given id exists.

      Specified by:

      exists in interface GetService<T,ID>

      Parameters:

      id - the id of the object

      Returns:

      true if the object exists, false otherwise

    • count

      public long count(@Nullable Filter filter)

      Counts the number of entities that match the given filter.

      Specified by:

      count in interface CountService

      Parameters:

      filter - the filter, or null to use no filter

      Returns:

    • toSpec

      protected org.springframework.data.jpa.domain.Specification<T> toSpec(@Nullable Filter filter)

      Converts the given filter to a JPA specification.

      Parameters:

      filter - the filter to convert

      Returns:

      a JPA specification

    • resolveEntityClass

      protected Class<T> resolveEntityClass()