Interface WasteRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Waste,Long>, org.springframework.data.jpa.repository.JpaRepository<Waste,Long>, org.springframework.data.repository.ListCrudRepository<Waste,Long>, org.springframework.data.repository.ListPagingAndSortingRepository<Waste,Long>, org.springframework.data.repository.PagingAndSortingRepository<Waste,Long>, org.springframework.data.repository.query.QueryByExampleExecutor<Waste>, org.springframework.data.repository.Repository<Waste,Long>

public interface WasteRepository extends org.springframework.data.jpa.repository.JpaRepository<Waste,Long>
Repository for waste
Version:
1.1
Author:
Anders, Pedro
  • Method Summary

    Modifier and Type
    Method
    Description
    findAllWasteOfOneCategoryFromGroup(long groupId, String categoryName)
    Returns a list of all waste items of a given category from a specific group.
     
    long
    Gets the last added waste item

    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, flush, getById, getOne, getReferenceById, saveAllAndFlush, saveAndFlush

    Methods inherited from interface org.springframework.data.repository.ListCrudRepository

    findAll, findAllById, saveAll

    Methods inherited from interface org.springframework.data.repository.ListPagingAndSortingRepository

    findAll

    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 Details

    • findByGroupId

      Optional<List<Waste>> findByGroupId(Group groupId)
    • findAllWasteOfOneCategoryFromGroup

      @Query(value="SELECT * FROM wastes WHERE group_id = :groupId AND ean IN (SELECT ean FROM product WHERE category_name = :categoryName);", nativeQuery=true) Optional<List<Waste>> findAllWasteOfOneCategoryFromGroup(@Param("groupId") long groupId, @Param("categoryName") String categoryName)
      Returns a list of all waste items of a given category from a specific group.
      Parameters:
      groupId - the ID of the group
      categoryName - the name of the category
      Returns:
      an Optional containing a List of Waste objects if at least one waste item is found, or an empty Optional if no waste items are found
    • getLastWaste

      @Query(value="SELECT waste_id FROM wastes ORDER BY waste_id ASC", nativeQuery=true) long getLastWaste()
      Gets the last added waste item
      Returns:
      the id of the last added waste item