Interface SearchRepository<T,​ID extends Serializable>

    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method 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 getOne​(ID id)
      Deprecated.
      This is just a temporary methed to make migration to CrudRepository.findById(Object) more smooth.
      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.
      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>"!
      org.springframework.data.domain.Page<T> search​(SearchQuery<T> searchQuery, org.springframework.data.domain.Pageable pageable)
      Performs a paginated search with the given SearchQuery.
      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.
      • Methods inherited from interface org.springframework.data.repository.CrudRepository

        count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findById, save
      • Methods inherited from interface org.springframework.data.jpa.repository.JpaRepository

        deleteAllByIdInBatch, deleteAllInBatch, deleteAllInBatch, deleteInBatch, findAll, findAll, findAll, findAll, findAllById, flush, getById, getReferenceById, saveAll, saveAllAndFlush, saveAndFlush
      • Methods inherited from interface org.springframework.data.jpa.repository.JpaSpecificationExecutor

        count, exists, findAll, findAll, findAll, findOne
      • Methods inherited from interface org.springframework.data.repository.PagingAndSortingRepository

        findAll
      • Methods inherited from interface org.springframework.data.repository.query.QueryByExampleExecutor

        count, exists, findAll, findBy, findOne
    • Method Detail

      • getOne

        @Deprecated
        T getOne​(ID id)
        Deprecated.
        This is just a temporary methed to make migration to CrudRepository.findById(Object) more smooth.
        Retrieves an entity by its id.
        Specified by:
        getOne in interface org.springframework.data.jpa.repository.JpaRepository<T,​ID extends Serializable>
        Parameters:
        id - must not be null.
        Returns:
        the entity with the given id or null if none found.
        Throws:
        IllegalArgumentException - if id is null.
      • isUnique

        boolean isUnique​(ID id,
                         String property,
                         Object value)
        Checks whether the given property is unique for this domain type.
        Parameters:
        id - the ID of the entity to check, may be null if it's a new entity
        property - 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
        Returns:
        true, if there is no other entity where the given property has the given value, false otherwise
      • isUnique

        boolean isUnique​(ID id,
                         String[] properties,
                         Object[] values)
        Checks whether the given properties are unique for this domain type.
        Parameters:
        id - the ID of the entity to check, may be null if it's a new entity
        properties - 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
        Returns:
        true, if there is no other entity where the given properties have the given values, false otherwise
      • search

        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. This means, if Pageable.getOffset() returns a higher number than Page.getTotalElements(), a new Pageable is created, starting with page 0.
        Parameters:
        pageable - a Pageable
        Returns:
        a Page containing the result
      • search

        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>"!
        Parameters:
        queryString - the JPQL-query, starting with "from <Entity> <entityName>"
        entityName - the alias used for the entity within the query.
        E.g. if your query is 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).
        Returns:
        a Page containing the result
      • search

        List<T> search​(String queryString,
                       Object... params)
        Performs a search with the given query-String.
        Parameters:
        queryString - the JPQL-query
        params - the parameters to be applied to the Query, using Query.setParameter(int, Object).
        Returns:
        a Page containing the result
      • search

        org.springframework.data.domain.Page<T> search​(SearchQuery<T> searchQuery,
                                                       org.springframework.data.domain.Pageable pageable)
        Performs a paginated search with the given SearchQuery.
        Parameters:
        searchQuery - the SearchQuery
        pageable - a Pageable (optional)
        Returns:
        a Page containing the result. When pageable is null, a single page containing all results will be returned
      • getHistory

        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).
        Parameters:
        id - the ID of the entity
        Returns:
        the previous revisions of the entity, if any
      • getRevision

        T getRevision​(ID id,
                      Number revision)
        Returns the requested revision of the entity with the requested ID (if the domain-class is audited);
        Parameters:
        id - the ID of the entity
        revision - the revision of the entity
        Returns:
        the requested revision of the entity with the requested ID. If either the entity or the revision does not exist, null is returned.
      • getRevisionNumber

        Number getRevisionNumber​(ID id)
        If the domain-class is audited, the latest revision number of the entity is returned.
        Parameters:
        id - the ID of the entity to get the revision for.
        Returns:
        the revision of the entity, or null if the domain-class is not audited or an entity with this ID does not exist
      • detach

        void detach​(T entity)
        Detaches the entity from the underlying EntityManager.
        Parameters:
        entity - the entity to detach