Class JpaCrudService<T,K>

java.lang.Object
com.flowingcode.backendcore.service.JpaCrudService<T,K>
All Implemented Interfaces:
CreationService<T,K>, CrudService<T,K>, DeletionService<T>, QueryService<T,K>, UpdateService<T>

public abstract class JpaCrudService<T,K> extends Object implements CrudService<T,K>
  • Constructor Details

    • JpaCrudService

      public JpaCrudService()
  • Method Details

    • getCrudRepository

      protected abstract org.springframework.data.repository.CrudRepository<T,K> getCrudRepository()
    • getExecutor

      protected abstract org.springframework.data.jpa.repository.JpaSpecificationExecutor<T> getExecutor()
    • buildSpecification

      protected org.springframework.data.jpa.domain.Specification<T> buildSpecification(com.flowingcode.backendcore.model.QuerySpec spec)
    • getId

      protected K getId(T entity)
      Default implementation for obtaining an id from an entity by calling method getId() by reflection
      Parameters:
      entity -
      Returns:
    • findById

      public Optional<T> findById(K id)
      Specified by:
      findById in interface QueryService<T,K>
    • findAll

      public List<T> findAll()
      Specified by:
      findAll in interface QueryService<T,K>
    • filter

      public List<T> filter(com.flowingcode.backendcore.model.QuerySpec filter)
      Specified by:
      filter in interface QueryService<T,K>
    • filterWithSingleResult

      public Optional<T> filterWithSingleResult(com.flowingcode.backendcore.model.QuerySpec filter)
      Specified by:
      filterWithSingleResult in interface QueryService<T,K>
    • count

      public long count(com.flowingcode.backendcore.model.QuerySpec filter)
      Specified by:
      count in interface QueryService<T,K>
    • save

      public K save(T entity)
      Specified by:
      save in interface CreationService<T,K>
    • update

      public void update(T entity)
      Specified by:
      update in interface UpdateService<T>
    • delete

      public void delete(T entity)
      Specified by:
      delete in interface DeletionService<T>
    • deleteById

      public void deleteById(K id)
      Specified by:
      deleteById in interface CrudService<T,K>