package cz.muni.fi.pa165.soccermanager.repository;

import cz.muni.fi.pa165.soccermanager.entity.League;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface LeagueRepository extends JpaRepository<League, Long> {

  @Query("SELECT " +
          "CASE " +
          "WHEN COUNT( l ) > 0  THEN true " +
          "ELSE " +
          "false " +
          "END " +
          "FROM League l WHERE l.name = :name"
  )
  Boolean leagueNameExists(String name);
}
