package com.eyrolles.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.eyrolles.model.Livre;

public interface LivreRepository extends JpaRepository<Livre, Integer> {
	@Query("select l from Livre l where l.theme.id=:idTheme")
	public Page<Livre> getAll(@Param("idTheme")int idTheme,Pageable pageable);
	@Query("select l from Livre l where l.categorie.id=:idCategory")
	public Page<Livre> getByCategorie(@Param("idCategory")int idCategory,Pageable pageable);
	@Query("select l from Livre l where l.sousCategorie.id=:idSubCategory")
	public Page<Livre> getBySubCategorie(@Param("idSubCategory")int idSubCategory,Pageable pageable);
	@Query("select l from Livre l where l.titre like %:mc%")
	public Page<Livre> getByMC(@Param("mc")String mc,Pageable page);
}
