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

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

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

import com.ecep.contract.model.Contract;
import com.ecep.contract.model.PurchaseOrder;

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

    Optional<PurchaseOrder> findByCode(String code);

    Optional<PurchaseOrder> findByRefId(Integer refId);

    List<PurchaseOrder> findAllByContract(Contract contract);

    List<PurchaseOrder> findByCodeStartsWith(String code);
}
