Interface FridgeItemsRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<FridgeItems,
,FridgeItemsId> org.springframework.data.jpa.repository.JpaRepository<FridgeItems,
,FridgeItemsId> org.springframework.data.jpa.repository.JpaSpecificationExecutor<FridgeItems>
,org.springframework.data.repository.ListCrudRepository<FridgeItems,
,FridgeItemsId> org.springframework.data.repository.ListPagingAndSortingRepository<FridgeItems,
,FridgeItemsId> org.springframework.data.repository.PagingAndSortingRepository<FridgeItems,
,FridgeItemsId> org.springframework.data.repository.query.QueryByExampleExecutor<FridgeItems>
,org.springframework.data.repository.Repository<FridgeItems,
FridgeItemsId>
@Repository
public interface FridgeItemsRepository
extends org.springframework.data.jpa.repository.JpaRepository<FridgeItems,FridgeItemsId>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<FridgeItems>
This repository provides CRUD operations for the FridgeItem entity.
It extends JpaRepository and JpaSpecificationExecutor interfaces.
JpaRepository provides basic CRUD operations while JpaSpecificationExecutor provides
search functionality using specifications.
-
Method Summary
Modifier and TypeMethodDescriptionfindAllByFridge_FridgeId
(Long fridgeId) This method retrieves a list of all the fridge items from a given fridge.findByFridge
(Fridge fridge) Find FridgeItems by fridgefindByItem_ItemIdAndFridge_FridgeId
(Long itemId, Long fridgeId) Find a FridgeItem by item ID and fridge IDfindByItem_ProductName
(String productName) Find a fridgeItem with the given namefindByItem_ProductNameAndItem_Store_StoreNameAndFridge_FridgeId
(String productName, String storeName, Long fridgeId) Find a fridgeItem with the given namefindByItemAndFridge
(Item item, Fridge fridge) Find a FridgeItem by items and fridgefindFridgeItemsByPurchaseDateBefore
(@NonNull LocalDateTime purchaseDate) Finds fridge items with purchase dates before a given date.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.jpa.repository.JpaSpecificationExecutor
count, delete, exists, findAll, findAll, findAll, findBy, findOne
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
-
findByItem_ProductName
Find a fridgeItem with the given name- Parameters:
productName
- The name of the product- Returns:
- An Optional containing the FridgeItem, or an empty Optional if not found
-
findByItem_ProductNameAndItem_Store_StoreNameAndFridge_FridgeId
Optional<FridgeItems> findByItem_ProductNameAndItem_Store_StoreNameAndFridge_FridgeId(String productName, String storeName, Long fridgeId) Find a fridgeItem with the given name- Parameters:
productName
- The name of the productstoreName
- The name of the store the product comes fromfridgeId
- The ID of the fridge- Returns:
- An Optional containing the FridgeItem, or an empty Optional if not found
-
findByItemAndFridge
Find a FridgeItem by items and fridge- Parameters:
item
- The items of productfridge
- the fridge to search in- Returns:
- An Optional containing the FridgeItem, or an empty Optional if not found
-
findByItem_ItemIdAndFridge_FridgeId
Find a FridgeItem by item ID and fridge ID- Parameters:
itemId
- The items of product, given by a Long objectfridgeId
- The fridge to search in, given by a Long object- Returns:
- An Optional containing the FridgeItem, or an empty Optional if not found
-
findByFridge
Find FridgeItems by fridge- Parameters:
fridge
- the fridge to search in- Returns:
- An Optional containing the FridgeItem, or an empty Optional if not found
-
findFridgeItemsByPurchaseDateBefore
Optional<List<FridgeItems>> findFridgeItemsByPurchaseDateBefore(@NonNull @NonNull LocalDateTime purchaseDate) Finds fridge items with purchase dates before a given date.- Parameters:
purchaseDate
- Date of purchase.- Returns:
- An optional list of items with purchase dates before a given items.
-
findAllByFridge_FridgeId
This method retrieves a list of all the fridge items from a given fridge.- Parameters:
fridgeId
- The ID of the fridge, given as a Long- Returns:
- An optional containing the list of fridge items.
-