package com.ecep.contract.ds.company.repository;

import java.util.List;

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.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ecep.contract.model.CompanyOldName;

@Repository
public interface CompanyOldNameRepository extends
        // JDBC interfaces
        CrudRepository<CompanyOldName, Integer>, PagingAndSortingRepository<CompanyOldName, Integer>,
        // JPA interfaces
        JpaRepository<CompanyOldName, Integer>, JpaSpecificationExecutor<CompanyOldName> {

    List<CompanyOldName> findAllByCompanyId(Integer companyId);

    List<CompanyOldName> findAllByCompanyIdAndName(Integer companyId, String name);

    List<CompanyOldName> findAllByName(String name);

    List<CompanyOldName> findByNameLike(String searchText);

    List<CompanyOldName> findByMemoLike(String searchText);

    @Modifying
    @Transactional
    int deleteAllByCompanyId(Integer companyId);

}
