package ru.kayashov.bar.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import ru.kayashov.bar.model.entity.TypeEntity;

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

public interface TypeRepository extends JpaRepository<TypeEntity, Long> {

    Optional<TypeEntity> findByEnNameIgnoreCase(String name);

    Optional<TypeEntity> findByName(String name);

    @Query("select i from TypeEntity i where upper(i.name) like upper(?1) or upper(i.enName) like upper(?1)")
    List<TypeEntity> findByWord(String word);
}