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

import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiRichiestaPfAmmto;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DpianificFerieAmmto;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiRichiestaPfAmmtoKey;

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

@Repository
@EnableJpaRepositories
public interface DrichPianifFerieAmmtoRepository
		extends BaseRepository<DrichPianifFerieAmmto, DrichPianifFerieAmmtoKey> {

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

	Optional<DrichPianifFerieAmmto> findByDrichPianifFerieAmmtoKey(DrichPianifFerieAmmtoKey id);

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

	Page<DrichPianifFerieAmmto> findByTheDstatiRichiestaPfAmmto(DstatiRichiestaPfAmmto parentEntity, Pageable pageable);

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

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

	@Query("DELETE FROM DrichPianifFerieAmmto WHERE drichPianifFerieAmmtoKey IN ?1")
	void deleteByIdIn(Collection<DrichPianifFerieAmmtoKey> ids);
}
