Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import jakarta.data.Limit;
import jakarta.data.Order;
import jakarta.data.Sort;
import jakarta.data.Sort.Nulls;
import jakarta.data.constraint.AtLeast;
import jakarta.data.constraint.AtMost;
Expand All @@ -43,8 +44,10 @@
import jakarta.data.repository.By;
import jakarta.data.repository.CrudRepository;
import jakarta.data.repository.Find;
import jakarta.data.repository.First;
import jakarta.data.repository.Is;
import jakarta.data.repository.OrderBy;
import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;
import jakarta.data.repository.Select;
import jakarta.data.restrict.Restriction;
Expand All @@ -57,6 +60,12 @@
@Repository
public interface Countries extends CrudRepository<Country, String> {

@Find
@First(3)
@OrderBy(value = _Country.NAME)
Country[] alphabetizedAfter(
@By(_Country.NAME) @Is(GreaterThan.class) String startAfter);

@Find
@OrderBy(value = _Country.DAYLIGHTTIMEENDS,
nullOrdering = Nulls.LAST)
Expand Down Expand Up @@ -122,6 +131,16 @@ List<Country> findLargest(
@By(_Country.POPULATION) @Is(AtLeast.class) long minPopulation,
Order<Country> order);

@Find
@First
List<Country> firstOf(Order<Country> order);

@Find
@First(4)
@OrderBy(value = _Country.POPULATION, descending = true)
List<Country> fourMostPopulousOf(
@By(_Country.CODE) @Is(In.class) List<String> codes);

@Find
List<Country> highlyPopulousInRegion(
@By(_Country.REGION) EqualTo<Region> region,
Expand All @@ -136,10 +155,32 @@ Stream<Country> inRegion(
List<Country> inSomeOtherRegionThan(
@By(_Country.REGION) NotEqualTo<Region> exclude);

@Find
@First(15)
List<Country> largest15Matching(@By(_Country.NAME) Like pattern,
Order<Country> order);

@First
@Query("WHERE code IS NOT NULL ORDER BY area DESC")
Optional<Country> largestByArea();

@Find
@First
Optional<Country> leastBy(Sort<Country> sort);

@Find
List<Country> lessPopulousThan(
@By(_Country.POPULATION) LessThan<Long> threshold);

@Find
@First
@OrderBy(value = _Country.POPULATION, descending = true)
Country mostPopulous();

@First(5)
@Query("WHERE region = ?1 ORDER BY population DESC")
List<Country> mostPopulousIn(Region region);

@Find
List<Country> namedAnyOf(
@By(_Country.NAME) In<String> names);
Expand All @@ -160,6 +201,12 @@ Stream<Country> namedUnlike(
List<Country> namedUpTo(
@Is(AtMost.class) String name);

@Query("FROM Country WHERE code > ?1")
@Select(_Country.CODE)
@First
@OrderBy(_Country.CODE)
Optional<String> nextCode(String currentCode);

@Find
List<Country> notInRegions(
@By(_Country.REGION) NotIn<Region> excluded);
Expand Down
Loading