Interface FridgeRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Fridge,
,Long> org.springframework.data.jpa.repository.JpaRepository<Fridge,
,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<Fridge>
,org.springframework.data.repository.ListCrudRepository<Fridge,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<Fridge,
,Long> org.springframework.data.repository.PagingAndSortingRepository<Fridge,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<Fridge>
,org.springframework.data.repository.Repository<Fridge,
Long>
@Repository
public interface FridgeRepository
extends org.springframework.data.jpa.repository.JpaRepository<Fridge,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<Fridge>
This repository provides CRUD operations for the Fridge entity.
It extends JpaRepository and JpaSpecificationExecutor interfaces.
JpaRepository provides basic CRUD operations while JpaSpecificationExecutor provides
search functionality using specifications.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
findByFridgeId
(Long fridgeId) Finds a fridge by its fridge ID.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
-
findByFridgeId
Finds a fridge by its fridge ID.- Parameters:
fridgeId
- the ID of the fridge to find- Returns:
- an Optional containing the fridge with the given ID, or an empty Optional if no such fridge exists
-
createTriggerForDeletingMember
@Modifying @Transactional @Query(value="CREATE TRIGGER fridge_member_deleted AFTER DELETE ON fridge_members FOR EACH ROW BEGIN IF OLD.super_user = 1 THEN IF NOT EXISTS(SELECT 1 FROM fridge_members WHERE fridge_id = OLD.fridge_id AND super_user = 1) THEN DELETE FROM fridge WHERE fridge.fridge_id = OLD.fridge_id; END IF; END IF; END; ", nativeQuery=true) @Profile("!test") void createTriggerForDeletingMember() -
dropMemberTrigger
@Modifying @Transactional @Query(value="DROP TRIGGER IF EXISTS fridge_member_deleted", nativeQuery=true) @Profile("!test") void dropMemberTrigger() -
createTriggerForNullingFridgeStats
@Modifying @Transactional @Query(value="CREATE TRIGGER fridge_deleted BEFORE DELETE ON fridge FOR EACH ROW BEGIN UPDATE stats SET fridge_id = NULL WHERE fridge_id = OLD.fridge_id; END;", nativeQuery=true) @Profile("!test") void createTriggerForNullingFridgeStats() -
dropStatsTrigger
@Modifying @Transactional @Query(value="DROP TRIGGER IF EXISTS fridge_deleted", nativeQuery=true) @Profile("!test") void dropStatsTrigger()
-