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.SalesOrder;

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

    Optional<SalesOrder> findByCode(String code);

    List<SalesOrder> findAllByContract(Contract contract);

    List<SalesOrder> findByCodeStartsWith(String code);
}
