package com.its.api.its.repository.ifsc;

import com.its.api.its.model.entity.ifsc.TbIfscTraf;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface TbIfscTrafRepository extends JpaRepository<TbIfscTraf, Long>, JpaSpecificationExecutor<TbIfscTraf> {

    @Query("select p from TbIfscTraf p inner join fetch p.ifsc")
    List<TbIfscTraf> findAll();

    @Query("select p from TbIfscTraf p")
    List<TbIfscTraf> findAllTraf();

    @Query("select p from TbIfscTraf p inner join fetch p.ifsc where p.ifscId = :ifscId")
    Optional<TbIfscTraf> findById(@Param("ifscId") Long ifscId);

}
