Package 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 Summary
ConstructorsConstructorDescriptionListRepositoryService
(R repository) Creates the service using the given repository. -
Method Summary
Modifier and TypeMethodDescriptionlong
Counts the number of entities that match the given filter.boolean
Checks if an object with the given id exists.Gets the object with the given id.protected R
Accessor for the repository instance.Lists objects of the given type using the paging, sorting and filtering options provided in the parameters.protected org.springframework.data.jpa.domain.Specification<T>
Converts the given filter to a JPA specification.
-
Constructor Details
-
ListRepositoryService
public ListRepositoryService() -
ListRepositoryService
Creates the service using the given repository.- Parameters:
repository
- the JPA repository
-
-
Method Details
-
getRepository
Accessor for the repository instance.- Returns:
- the repository instance
-
list
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 interfaceListService<T>
- Parameters:
pageable
- contains information about paging and sortingfilter
- the filter to apply ornull
to not filter- Returns:
- a list of objects or an empty list if no objects were found
-
get
Description copied from interface:GetService
Gets the object with the given id.- Specified by:
get
in interfaceGetService<T,
ID> - Parameters:
id
- the id of the object- Returns:
- the object, or an empty optional if no object with the given id
-
exists
Description copied from interface:GetService
Checks if an object with the given id exists.- Specified by:
exists
in interfaceGetService<T,
ID> - Parameters:
id
- the id of the object- Returns:
true
if the object exists,false
otherwise
-
count
Counts the number of entities that match the given filter.- Specified by:
count
in interfaceCountService
- Parameters:
filter
- the filter, ornull
to use no filter- Returns:
-
toSpec
Converts the given filter to a JPA specification.- Parameters:
filter
- the filter to convert- Returns:
- a JPA specification
-
resolveEntityClass
-