package com.its.api.its.repository.vms;

import com.its.api.its.model.entity.vms.TbVmsLumSetSch;
import com.its.api.its.model.entity.vms.TbVmsLumSetSchKey;
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 TbVmsLumSetSchRepository extends JpaRepository<TbVmsLumSetSch, TbVmsLumSetSchKey>, JpaSpecificationExecutor<TbVmsLumSetSch> {

    @Query("select p from TbVmsLumSetSch p inner join fetch p.vms where p.vmsCtlrNmbr = :id and p.schTime = :schTime")
    Optional<TbVmsLumSetSch> findByKey(@Param("id") Long id, @Param("schTime") String schTime);

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

}
