package it.micegroup.gestioneferie.pianificazioneferie.repository;

import org.springframework.stereotype.Repository;

import java.util.Optional;
import java.util.Collection;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.EntityGraph.EntityGraphType;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DrichiesteApprovazPf;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DrichiesteApprovazPfKey;

import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiRichApprovPf;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DpianiFerie;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiRichApprovPfKey;
import it.micegroup.gestioneferie.libs.repository.BaseRepository;

@Repository
@EnableJpaRepositories
public interface DrichiesteApprovazPfRepository extends BaseRepository<DrichiesteApprovazPf, DrichiesteApprovazPfKey> {

	@EntityGraph(attributePaths = { "theDstatiRichApprovPf", "theDpianiFerie" }, type = EntityGraphType.FETCH)

	Optional<DrichiesteApprovazPf> findByDrichiesteApprovazPfKey(DrichiesteApprovazPfKey id);

	@EntityGraph(attributePaths = { "theDstatiRichApprovPf", "theDpianiFerie" }, type = EntityGraphType.FETCH)

	Page<DrichiesteApprovazPf> findByTheDstatiRichApprovPf(DstatiRichApprovPf parentEntity, Pageable pageable);

	@EntityGraph(attributePaths = { "theDstatiRichApprovPf", "theDpianiFerie" }, type = EntityGraphType.FETCH)

	Page<DrichiesteApprovazPf> findByTheDpianiFerie(DpianiFerie parentEntity, Pageable pageable);

	@Query("DELETE FROM DrichiesteApprovazPf WHERE drichiesteApprovazPfKey IN ?1")
	void deleteByIdIn(Collection<DrichiesteApprovazPfKey> ids);
}
