Class CRUDServiceImpl<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>

    • Method Summary

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

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        @Transactional
        public ValueType create​(ValueType object)
                         throws javax.validation.ConstraintViolationException,
                                EntityExistsException
        Create a new object in the persistence store.
        Specified by:
        create in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        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:
        javax.validation.ConstraintViolationException - If the object being persisted cannot be validated by validation rules associated with the object.
        EntityExistsException - If the object being persisted violates uniqueness constraints in the database.
      • findAll

        @Transactional(readOnly=true)
        public java.lang.Iterable<ValueType> findAll()
        List all objects of Type in the database.
        Specified by:
        findAll in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Returns:
        All objects of the specified Type in the database.
      • exists

        @Transactional(readOnly=true)
        public java.lang.Boolean exists​(KeyType id)
        Check to see if an identifier for Type exists in the database.
        Specified by:
        exists in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        id - The identifier to check for.
        Returns:
        true if the identifier exists, false otherwise.
      • list

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<ValueType> list​(int page,
                                                                    int size,
                                                                    org.springframework.data.domain.Sort.Direction order,
                                                                    java.lang.String... sortProperties)
                                                             throws java.lang.IllegalArgumentException
        List objects of Type in the database, limited to some specific page.
        Specified by:
        list in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        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.
        sortProperties - the properties used to sort the collection.
        Returns:
        the list of users within the specified range.
        Throws:
        java.lang.IllegalArgumentException - If the Type has no public property sortProperty.
      • list

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<ValueType> list​(int page,
                                                                    int size,
                                                                    org.springframework.data.domain.Sort sort)
                                                             throws java.lang.IllegalArgumentException
        List objects of Type in the database, limited to some specific page
        Specified by:
        list in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        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
        Throws:
        java.lang.IllegalArgumentException
      • count

        @Transactional(readOnly=true)
        public long count()
        How many entities of Type exist in the database?
        Specified by:
        count in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Returns:
        the number of entities in the database.
      • updateFields

        @Transactional
        public ValueType updateFields​(KeyType id,
                                      java.util.Map<java.lang.String,​java.lang.Object> updatedFields)
                               throws javax.validation.ConstraintViolationException,
                                      EntityExistsException,
                                      InvalidPropertyException
        Update properties of the given object by given fields. The object must have a valid identifier prior to being passed to this method.
        Specified by:
        updateFields in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        id - The identifier of the object to update.
        updatedFields - 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:
        javax.validation.ConstraintViolationException - If the object being persisted cannot be validated by validation rules associated with the object.
        EntityExistsException - If the object being persisted violates uniqueness constraints in the database.
        InvalidPropertyException - If the updated properties map contains a property name that does not exist on the domain model.
      • list

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<ValueType> 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.
        Specified by:
        list in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        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.
      • readMultiple

        @Transactional(readOnly=true)
        public java.lang.Iterable<ValueType> readMultiple​(java.lang.Iterable<KeyType> idents)
        Read multiple objects by the given collection of identifiers
        Specified by:
        readMultiple in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        idents - The unique identifiers of the objects to read
        Returns:
        A collection of the requested objects
      • search

        @Deprecated
        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<ValueType> search​(org.springframework.data.jpa.domain.Specification<ValueType> specification,
                                                                      int page,
                                                                      int size,
                                                                      org.springframework.data.domain.Sort.Direction order,
                                                                      java.lang.String... sortProperties)
        Deprecated.
        Search for an entity of Type with a given specification
        Specified by:
        search in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        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

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<ValueType> search​(org.springframework.data.jpa.domain.Specification<ValueType> specification,
                                                                      org.springframework.data.domain.Pageable pageRequest)
        Search for an entity of Type and PageRequest
        Specified by:
        search in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        specification - The search Specification
        pageRequest - The PageRequest
        Returns:
        a Page of Type
      • findRevisions

        @Transactional(readOnly=true)
        public org.springframework.data.history.Revisions<java.lang.Integer,​ValueType> findRevisions​(KeyType id)
        Find all of the revisions for the specified identifier.
        Specified by:
        findRevisions in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        id - the identifier to find revisions for.
        Returns:
        the collection of revisions for the identifier.
      • findRevisions

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<org.springframework.data.history.Revision<java.lang.Integer,​ValueType>> findRevisions​(KeyType id,
                                                                                                                                                org.springframework.data.domain.Pageable pageable)
        Returns a Page of revisions for the entity with the given id.
        Specified by:
        findRevisions in interface CRUDService<KeyType extends java.io.Serializable,​ValueType extends Timestamped<KeyType>>
        Parameters:
        id - the identifier to find revisions for.
        pageable - the page specification.
        Returns:
        the page of revisions for the specified resource.