File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/main/java/com/grouptwelve/grouptwelveBE/repository Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .grouptwelve .grouptwelveBE .repository ;
2+
3+ import com .grouptwelve .grouptwelveBE .model .FootballTeam ;
4+ import org .springframework .data .jpa .repository .JpaRepository ;
5+ import org .springframework .data .jpa .repository .Query ;
6+ import org .springframework .data .repository .query .Param ;
7+
8+ import java .util .List ;
9+ import java .util .Optional ;
10+
11+ public interface FootballTeamRepository extends JpaRepository <FootballTeam , Long > {
12+
13+ // ---- Derived queries matching your entity fields ----
14+ List <FootballTeam > findByHomeTeamIgnoreCase (String homeTeam );
15+ List <FootballTeam > findByAwayTeamIgnoreCase (String awayTeam );
16+ Optional <FootballTeam > findByHomeTeamIgnoreCaseAndAwayTeamIgnoreCase (String homeTeam , String awayTeam );
17+ List <FootballTeam > findByHomeTeamContainingIgnoreCase (String partial );
18+ List <FootballTeam > findByAwayTeamContainingIgnoreCase (String partial );
19+
20+ @ Query ("""
21+ SELECT f FROM FootballTeam f
22+ WHERE LOWER(f.homeTeam) LIKE LOWER(CONCAT('%', :q, '%'))
23+ OR LOWER(f.awayTeam) LIKE LOWER(CONCAT('%', :q, '%'))
24+ """ )
25+ List <FootballTeam > search (@ Param ("q" ) String q );
26+ }
You can’t perform that action at this time.
0 commit comments