package it.micegroup.gestioneferie.configurazionepf.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.configurazionepf.entity.DpercAutPianFerieH;

import it.micegroup.gestioneferie.configurazionepf.entity.DpercAutPianFeriePk;
import it.micegroup.gestioneferie.configurazionepf.entity.DconfigPaPianiFerie;
import it.micegroup.gestioneferie.libs.repository.BaseRepository;

@Repository
@EnableJpaRepositories
public interface DpercAutPianFerieHRepository extends BaseRepository<DpercAutPianFerieH, Long> {

	@EntityGraph(attributePaths = { "theDpercAutPianFeriePk", "theDconfigPaPianiFerie" }, type = EntityGraphType.FETCH)

	Optional<DpercAutPianFerieH> findBySequIdPercAutPianFerieH(Long id);

	@EntityGraph(attributePaths = { "theDpercAutPianFeriePk", "theDconfigPaPianiFerie" }, type = EntityGraphType.FETCH)

	Page<DpercAutPianFerieH> findByTheDpercAutPianFeriePk(DpercAutPianFeriePk parentEntity, Pageable pageable);

	@EntityGraph(attributePaths = { "theDpercAutPianFeriePk", "theDconfigPaPianiFerie" }, type = EntityGraphType.FETCH)

	Page<DpercAutPianFerieH> findByTheDconfigPaPianiFerie(DconfigPaPianiFerie parentEntity, Pageable pageable);

	@Query("DELETE FROM DpercAutPianFerieH WHERE sequIdPercAutPianFerieH IN ?1")
	void deleteByIdIn(Collection<Long> ids);
}
