package de.thpeetz.kontor.comics.repository;

import java.util.List;

import de.thpeetz.kontor.comics.data.*;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface TradePaperbackRepository extends JpaRepository<TradePaperback, String> {
    @Query("select t from TradePaperback t " +
            "where lower(t.name) like lower(concat('%', :searchTerm, '%')) ")
    List<TradePaperback> search(@Param("searchTerm") String searchTerm);

    List<TradePaperback> findByComic(Comic comic);

    List<TradePaperback> findByNameAndComic(String name, Comic comic);

    @Query("select t from TradePaperback t where t.name = ?1 and t.comic = ?2 and t.issueStart = ?3 and t.issueEnd = ?4")
    TradePaperback findByFields(String name, Comic comic, int start, int end);
}
