package com.its.api.its.repository.incident;

import com.its.api.its.model.entity.incident.TbIncdEstmSect;
import com.its.api.its.model.entity.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> {

    @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();

}
