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.SalesOrder;
import com.ecep.contract.model.SalesOrderItem;

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

    Optional<SalesOrderItem> findByCode(String code);

    List<SalesOrderItem> findAllByOrder(SalesOrder order);

    List<SalesOrderItem> findByCodeStartsWith(String code);
}
