Interface CRUDService<IdentifierType extends java.io.Serializable,​Type extends Timestamped<IdentifierType>>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long count()
      How many entities of Type exist in the database?
      Type create​(Type object)
      Create a new object in the persistence store.
      void delete​(IdentifierType id)
      Delete the object with the specified identifier from the database.
      java.lang.Boolean exists​(IdentifierType id)
      Check to see if an identifier for Type exists in the database.
      java.lang.Iterable<Type> findAll()
      List all objects of Type in the database.
      org.springframework.data.history.Revisions<java.lang.Integer,​Type> findRevisions​(IdentifierType id)
      Find all of the revisions for the specified identifier.
      org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,​Type>> findRevisions​(IdentifierType id, org.springframework.data.domain.Pageable pageable)
      Returns a Page of revisions for the entity with the given id.
      org.springframework.data.domain.Page<Type> list​(int page, int size, org.springframework.data.domain.Sort sort)
      List objects of Type in the database, limited to some specific page
      org.springframework.data.domain.Page<Type> list​(int page, int size, org.springframework.data.domain.Sort.Direction order)
      List objects of Type in the database, limited to some specific page, ordered by calling the compareTo method on the class.
      org.springframework.data.domain.Page<Type> list​(int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperty)
      List objects of Type in the database, limited to some specific page.
      Type read​(IdentifierType id)
      Read the object type by unique identifier.
      java.lang.Iterable<Type> readMultiple​(java.lang.Iterable<IdentifierType> idents)
      Read multiple objects by the given collection of identifiers
      org.springframework.data.domain.Page<Type> search​(org.springframework.data.jpa.domain.Specification<Type> specification, int page, int size, org.springframework.data.domain.Sort.Direction order, java.lang.String... sortProperties)
      Search for an entity of Type with a given specification
      org.springframework.data.domain.Page<Type> search​(org.springframework.data.jpa.domain.Specification<Type> specification, org.springframework.data.domain.Pageable pageRequest)
      Search for an entity of Type and PageRequest
      Type update​(Type object)
      Update an object
      Type updateFields​(IdentifierType id, java.util.Map<java.lang.String,​java.lang.Object> updatedProperties)
      Update properties of the given object by given fields.
      java.util.Collection<Type> updateMultiple​(java.util.Collection<Type> objects)
      Update multiple objects at once
    • Method Detail

      • create

        Type create​(@Valid
                    Type object)
             throws EntityExistsException,
                    javax.validation.ConstraintViolationException
        Create a new object in the persistence store.
        Parameters:
        object - The object to persist.
        Returns:
        The object as it was persisted in the database. May modify the identifier of the object when returned.
        Throws:
        EntityExistsException - If the object being persisted violates uniqueness constraints in the database.
        javax.validation.ConstraintViolationException - If the object being persisted cannot be validated by validation rules associated with the object.
      • readMultiple

        java.lang.Iterable<Type> readMultiple​(java.lang.Iterable<IdentifierType> idents)
        Read multiple objects by the given collection of identifiers
        Parameters:
        idents - The unique identifiers of the objects to read
        Returns:
        A collection of the requested objects
      • updateFields

        Type updateFields​(IdentifierType id,
                          java.util.Map<java.lang.String,​java.lang.Object> updatedProperties)
                   throws EntityExistsException,
                          EntityNotFoundException,
                          javax.validation.ConstraintViolationException,
                          InvalidPropertyException
        Update properties of the given object by given fields. The object must have a valid identifier prior to being passed to this method.
        Parameters:
        id - The identifier of the object to update.
        updatedProperties - the object properties that should be updated.
        Returns:
        The object as it was persisted in the database. May modify the identifier of the object when returned.
        Throws:
        EntityExistsException - If the object being persisted violates uniqueness constraints in the database.
        EntityNotFoundException - If no object with the supplied identifier exists in the database.
        javax.validation.ConstraintViolationException - If the object being persisted cannot be validated by validation rules associated with the object.
        InvalidPropertyException - If the updated properties map contains a property name that does not exist on the domain model.
      • update

        Type update​(Type object)
             throws EntityNotFoundException,
                    javax.validation.ConstraintViolationException
        Update an object
        Parameters:
        object - The object to update
        Returns:
        The updated object
        Throws:
        EntityNotFoundException - If the entity being updated is not in the database
        javax.validation.ConstraintViolationException - if the entity being updated contains constraint violations
      • updateMultiple

        java.util.Collection<Type> updateMultiple​(java.util.Collection<Type> objects)
                                           throws EntityNotFoundException,
                                                  javax.validation.ConstraintViolationException
        Update multiple objects at once
        Parameters:
        objects - the objects to update
        Returns:
        the updated objects
        Throws:
        EntityNotFoundException - if an entity being updated is not found in the database
        javax.validation.ConstraintViolationException - if an entity being updated contains constraint violations
      • delete

        void delete​(IdentifierType id)
             throws EntityNotFoundException
        Delete the object with the specified identifier from the database.
        Parameters:
        id - The identifier of the object to delete.
        Throws:
        EntityNotFoundException - If no object with the specified identifier exists in the database.
      • findAll

        java.lang.Iterable<Type> findAll()
        List all objects of Type in the database.
        Returns:
        All objects of the specified Type in the database.
      • list

        org.springframework.data.domain.Page<Type> list​(int page,
                                                        int size,
                                                        org.springframework.data.domain.Sort.Direction order,
                                                        java.lang.String... sortProperty)
                                                 throws java.lang.IllegalArgumentException
        List objects of Type in the database, limited to some specific page.
        Parameters:
        page - the specific page to use.
        size - the size of the pages used to compute the number of pages.
        sortProperty - the properties used to sort the collection.
        order - the order of the sort.
        Returns:
        the list of users within the specified range.
        Throws:
        java.lang.IllegalArgumentException - If the Type has no public property sortProperty.
      • list

        org.springframework.data.domain.Page<Type> list​(int page,
                                                        int size,
                                                        org.springframework.data.domain.Sort sort)
        List objects of Type in the database, limited to some specific page
        Parameters:
        page - the specific page to use
        size - the size of the pages
        sort - A Sort object for ordering the results
        Returns:
        a list of objects in the given range
      • list

        org.springframework.data.domain.Page<Type> list​(int page,
                                                        int size,
                                                        org.springframework.data.domain.Sort.Direction order)
        List objects of Type in the database, limited to some specific page, ordered by calling the compareTo method on the class.
        Parameters:
        page - the specific page to use.
        size - the size of the pages used to compute the number of pages.
        order - the order of the sort.
        Returns:
        the list of users within the specified range.
      • exists

        java.lang.Boolean exists​(IdentifierType id)
        Check to see if an identifier for Type exists in the database.
        Parameters:
        id - The identifier to check for.
        Returns:
        true if the identifier exists, false otherwise.
      • count

        long count()
        How many entities of Type exist in the database?
        Returns:
        the number of entities in the database.
      • search

        org.springframework.data.domain.Page<Type> search​(org.springframework.data.jpa.domain.Specification<Type> specification,
                                                          int page,
                                                          int size,
                                                          org.springframework.data.domain.Sort.Direction order,
                                                          java.lang.String... sortProperties)
        Search for an entity of Type with a given specification
        Parameters:
        specification - The search specification
        page - The page number
        size - the size of the page
        order - the order of the page sort
        sortProperties - The properties to sort on
        Returns:
        a Page of Type
      • search

        org.springframework.data.domain.Page<Type> search​(org.springframework.data.jpa.domain.Specification<Type> specification,
                                                          org.springframework.data.domain.Pageable pageRequest)
        Search for an entity of Type and PageRequest
        Parameters:
        specification - The search Specification
        pageRequest - The PageRequest
        Returns:
        a Page of Type
      • findRevisions

        org.springframework.data.history.Revisions<java.lang.Integer,​Type> findRevisions​(IdentifierType id)
        Find all of the revisions for the specified identifier.
        Parameters:
        id - the identifier to find revisions for.
        Returns:
        the collection of revisions for the identifier.
      • findRevisions

        org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,​Type>> findRevisions​(IdentifierType id,
                                                                                                                                    org.springframework.data.domain.Pageable pageable)
        Returns a Page of revisions for the entity with the given id.
        Parameters:
        id - the identifier to find revisions for.
        pageable - the page specification.
        Returns:
        the page of revisions for the specified resource.