package com.dacrt.SBIABackend.repository;

import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.dacrt.SBIABackend.entity.Applications;
import com.dacrt.SBIABackend.entity.Channels;
import com.dacrt.SBIABackend.entity.Evalprocapps;
import com.dacrt.SBIABackend.entity.Evalprocinputs;
import com.dacrt.SBIABackend.entity.Evalprocrecords;
import com.dacrt.SBIABackend.entity.Processes;
import com.dacrt.SBIABackend.security.entity.Users;

@Repository
public interface EvalprocinputsRepository extends JpaRepository<Evalprocinputs,Integer>,JpaSpecificationExecutor<Evalprocinputs>{
	boolean existsById(Integer id);
	
	@Query(value=" SELECT u FROM Evalprocinputs u WHERE u.id= ?1 ")
	Evalprocinputs getById(int id);
	
	@Query(value=" SELECT max(u.id) FROM Evalprocinputs u")
	int getMaxRecord();
	
	@Transactional
	@Modifying
	@Query(" DELETE FROM Evalprocinputs e where e.id = ?1 ")
	void deleteEvalprocInputssbyid(Integer id);
	
	boolean existsByIdAndEvalprocessid(int id,int evalprocessid);
	
	//select count(1) from  main.evalprocinputs where id = 11 and evalprocessid = 28
	@Query(value=" SELECT count(1) FROM Evalprocinputs u WHERE u.id = ?1 AND u.evalprocessid = ?2 ")
	int totalregrelacion(int id,int evalprocessid);

}