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

import com.its.op.entity.its.vms.TbVmsSymbIfsc;
import com.its.op.entity.its.vms.TbVmsSymbIfscKey;
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.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TbVmsSymbIfscRepository extends JpaRepository<TbVmsSymbIfsc, TbVmsSymbIfscKey>, JpaSpecificationExecutor<TbVmsSymbIfsc> {

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

    @Query("select p from TbVmsSymbIfsc p inner join fetch p.ifsc ifsc where p.symbLibNmbr = :id")
    List<TbVmsSymbIfsc> findDataById(@Param("id") Integer id);

    @Modifying
    @Query("delete from TbVmsSymbIfsc p where p.symbLibNmbr = :id")
    void deleteDataById(@Param("id") Integer id);
}
