Interface HolidayRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<HolidayEntity,
,Long> org.springframework.data.jpa.repository.JpaRepository<HolidayEntity,
,Long> org.springframework.data.jpa.repository.JpaSpecificationExecutor<HolidayEntity>
,org.springframework.data.repository.ListCrudRepository<HolidayEntity,
,Long> org.springframework.data.repository.ListPagingAndSortingRepository<HolidayEntity,
,Long> org.springframework.data.repository.PagingAndSortingRepository<HolidayEntity,
,Long> org.springframework.data.repository.query.QueryByExampleExecutor<HolidayEntity>
,org.springframework.data.repository.Repository<HolidayEntity,
Long>
public interface HolidayRepository
extends org.springframework.data.jpa.repository.JpaRepository<HolidayEntity,Long>, org.springframework.data.jpa.repository.JpaSpecificationExecutor<HolidayEntity>
Repository interface for managing
HolidayEntity
entities.
Extends JpaRepository
for basic CRUD operations and
JpaSpecificationExecutor
for complex queries.-
Method Summary
Modifier and TypeMethodDescriptionboolean
isHolidayAllow
(Long userId, LocalDateTime startDate, LocalDateTime endDate) Checks if there is any existing holiday for a given user that overlaps with the specified start and end dates, excluding holidays with status REJECTED.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
-
isHolidayAllow
@Query("select case when count(h) > 0 then true else false end from HolidayEntity h\nwhere h.userEntity.id = :userId\nand (:startDate between h.startDate and h.endDate\nor :endDate between h.startDate and h.endDate)\nand h.status != 'REJECTED'\n") boolean isHolidayAllow(Long userId, LocalDateTime startDate, LocalDateTime endDate) Checks if there is any existing holiday for a given user that overlaps with the specified start and end dates, excluding holidays with status REJECTED.The method returns
true
if at least one holiday exists that:- Belongs to the user identified by
userId
- Has a date range that overlaps with the interval between
startDate
andendDate
- Is not in REJECTED status
false
.- Parameters:
userId
- the ID of the user whose holidays to checkstartDate
- the start date of the requested holiday periodendDate
- the end date of the requested holiday period- Returns:
true
if there is an overlapping holiday for the user (excluding rejected holidays),false
otherwise
- Belongs to the user identified by
-