T
- the domain classID
- the type of the Id of the domain class@NoRepositoryBean
public interface SearchRepository<T,ID extends Serializable>
extends org.springframework.data.jpa.repository.JpaRepository<T,ID>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<T>
SearchRepository
provides several search-methods for a persistent domain-class.JpaRepository
,
JpaSpecificationExecutor
Modifier and Type | Method and Description |
---|---|
SearchQuery<T> |
createSearchQuery()
Creates and returns a new
SearchQuery . |
void |
detach(T entity)
Detaches the entity from the underlying
EntityManager . |
Collection<T> |
getHistory(ID id)
Returns all previous revisions (starting with the newest) for the entity with the given ID (if the domain-class
is audited).
|
T |
getRevision(ID id,
Number revision)
Returns the requested revision of the entity with the requested ID (if the domain-class is audited);
|
Number |
getRevisionNumber(ID id)
If the domain-class is audited, the latest revision number of the entity is returned.
|
boolean |
isUnique(ID id,
String[] properties,
Object[] values)
Checks whether the given properties are unique for this domain type.
|
boolean |
isUnique(ID id,
String property,
Object value)
Checks whether the given property is unique for this domain type.
|
org.springframework.data.domain.Page<T> |
search(org.springframework.data.domain.Pageable pageable)
Performs a paginated search.
In contrast to PagingAndSortingRepository.findAll(Pageable) , this method is able to re-calculate the
pagination. |
org.springframework.data.domain.Page<T> |
search(SearchQuery<T> searchQuery,
org.springframework.data.domain.Pageable pageable)
Performs a paginated search with the given
SearchQuery . |
List<T> |
search(String queryString,
Object... params)
Performs a search with the given query-String.
|
org.springframework.data.domain.Page<T> |
search(String queryString,
String entityName,
org.springframework.data.domain.Pageable pageable,
Object... params)
Performs a paginated search based upon the given query-String.Note that the query string must start with "from
<Entity> <entityName>"!
|
deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAll, flush, getOne, save, saveAndFlush
findAll
count, delete, delete, delete, deleteAll, exists, findOne, save
boolean isUnique(ID id, String property, Object value)
id
- the ID of the entity to check, may be null
if it's a new entityproperty
- the name of the property to check uniqueness for, must not be null
value
- the value of the property to check uniqueness for, must not be null
true
, if there is no other entity where the given property has the given value, false
otherwiseboolean isUnique(ID id, String[] properties, Object[] values)
id
- the ID of the entity to check, may be null
if it's a new entityproperties
- the names of the properties to check uniqueness for, must not be null
values
- the values of the properties to check uniqueness for, must not be null
true
, if there is no other entity where the given properties have the given values, false
otherwiseorg.springframework.data.domain.Page<T> search(org.springframework.data.domain.Pageable pageable)
PagingAndSortingRepository.findAll(Pageable)
, this method is able to re-calculate the
pagination. This means, if Pageable.getOffset()
returns a higher number than
Page.getTotalElements()
, a new Pageable
is created, starting with page 0.pageable
- a Pageable
Page
containing the resultorg.springframework.data.domain.Page<T> search(String queryString, String entityName, org.springframework.data.domain.Pageable pageable, Object... params)
queryString
- the JPQL-query, starting with "from <Entity> <entityName>"entityName
- the alias used for the entity within the query.from Foo f
, then the entityName needs to be f
.pageable
- a Pageable
params
- the parameters to be applied to the Query
, using
Query.setParameter(int, Object)
.Page
containing the resultList<T> search(String queryString, Object... params)
queryString
- the JPQL-queryparams
- the parameters to be applied to the Query
, using
Query.setParameter(int, Object)
.Page
containing the resultorg.springframework.data.domain.Page<T> search(SearchQuery<T> searchQuery, org.springframework.data.domain.Pageable pageable)
SearchQuery
.searchQuery
- the SearchQuery
pageable
- a Pageable
(optional)Page
containing the result. When pageable
is null, a single page containing all results
will be returnedCollection<T> getHistory(ID id)
id
- the ID of the entityT getRevision(ID id, Number revision)
id
- the ID of the entityrevision
- the revision of the entitynull
is returned.Number getRevisionNumber(ID id)
id
- the ID of the entity to get the revision for.null
if the domain-class is not audited or an entity with this ID
does not existvoid detach(T entity)
EntityManager
.entity
- the entity to detachSearchQuery<T> createSearchQuery()
SearchQuery
.SearchQuery
Copyright © 2011–2023 aiticon GmbH. All rights reserved.