package com.its.op.dao.repository.its.incident;

import com.its.op.entity.its.incident.TbIncdEstmSect;
import com.its.op.entity.its.incident.TbIncdEstmSectKey;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TbIncdEstmSectRepository extends JpaRepository<TbIncdEstmSect, TbIncdEstmSectKey>, JpaSpecificationExecutor<TbIncdEstmSect> {

    // 2시간 전 데이터 부터 조회
    @Query("select p from TbIncdEstmSect p inner join fetch p.link ln inner join fetch ln.fromNode fn inner join fetch ln.toNode tn " +
           " where p.detcDt >= to_char(sysdate - (2*60)/60/24, 'YYYYMMDDHH24MISS')")
    List<TbIncdEstmSect> findAll();

}
