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

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

public interface ChampionshipRepository extends JpaRepository<Championship, Long> {

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