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 TypeMethodDescriptionlongCounts the number of entities that match the given filter.booleanChecks if an object with the given id exists.Gets the object with the given id.protected RAccessor 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:ListServiceLists objects of the given type using the paging, sorting and filtering options provided in the parameters.- Specified by:
listin interfaceListService<T>- Parameters:
pageable- contains information about paging and sortingfilter- the filter to apply ornullto not filter- Returns:
- a list of objects or an empty list if no objects were found
-
get
Description copied from interface:GetServiceGets the object with the given id.- Specified by:
getin 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:GetServiceChecks if an object with the given id exists.- Specified by:
existsin interfaceGetService<T,ID> - Parameters:
id- the id of the object- Returns:
trueif the object exists,falseotherwise
-
count
Counts the number of entities that match the given filter.- Specified by:
countin interfaceCountService- Parameters:
filter- the filter, ornullto use no filter- Returns:
-
toSpec
Converts the given filter to a JPA specification.- Parameters:
filter- the filter to convert- Returns:
- a JPA specification
-
resolveEntityClass
-