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.DpianiFerie;

import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiPianoFerie;
import it.micegroup.gestioneferie.pianificazioneferie.entity.DstatiPianoFerieKey;
import it.micegroup.gestioneferie.libs.repository.BaseRepository;

@Repository
@EnableJpaRepositories
public interface DpianiFerieRepository extends BaseRepository<DpianiFerie, Long> {

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

	Optional<DpianiFerie> findBySequIdPianoFerie(Long id);

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

	Page<DpianiFerie> findByTheDstatiPianoFerie(DstatiPianoFerie parentEntity, Pageable pageable);

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