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

import com.its.op.entity.its.wcam.TbWcamCtlr;
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 TbWcamCtlrRepository extends JpaRepository<TbWcamCtlr, Long>, JpaSpecificationExecutor<TbWcamCtlr> {

    @Query("select p from TbWcamCtlr p left outer join fetch p.state state")
    List<TbWcamCtlr> findAll();

    @Query("select p from TbWcamCtlr p left outer join fetch p.state state where p.delYn = 'N'")
    List<TbWcamCtlr> findAllList();

    @Query(value = "SELECT NVL(MAX(WCAM_CTLR_NMBR), 0) + 1 AS NEWID FROM TB_WCAM_CTLR", nativeQuery = true)
    Long getNewNmbr();

}
