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.DperiodiAmmtoPf;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DperiodiAmmtoPfKey;

import it.micegroup.gestioneferie.pianificazioneferie.entity.DpianificFerieAmmto;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DpianificFerieAmmtoKey;
import it.micegroup.gestioneferie.libs.repository.BaseRepository;

@Repository
@EnableJpaRepositories
public interface DperiodiAmmtoPfRepository extends BaseRepository<DperiodiAmmtoPf, DperiodiAmmtoPfKey> {

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

	Optional<DperiodiAmmtoPf> findByDperiodiAmmtoPfKey(DperiodiAmmtoPfKey id);

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

	Page<DperiodiAmmtoPf> findByTheDpianificFerieAmmto(DpianificFerieAmmto parentEntity, Pageable pageable);

	@Query("DELETE FROM DperiodiAmmtoPf WHERE dperiodiAmmtoPfKey IN ?1")
	void deleteByIdIn(Collection<DperiodiAmmtoPfKey> ids);
}
