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

import com.its.op.entity.its.road.TbRoad;
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 TbRoadRepository extends JpaRepository<TbRoad, Long>, JpaSpecificationExecutor<TbRoad> {

    @Query("select p from TbRoad p inner join fetch p.fromNode fnode inner join fetch p.toNode tnode")
    List<TbRoad> findAll();

    @Query("select p from TbRoad p inner join fetch p.fromNode fnode inner join fetch p.toNode tnode where p.delYn = 'N'")
    List<TbRoad> findAllList();

    @Query("select count(p.roadId) from TbRoad p where p.delYn = 'N'")
    Integer findAllCount();

}
