ratnesh
ratnesh

Reputation: 569

spring data jpa "between" keyword

findByPointsBetween(Integer lowerlimit,Integer upperlimit); is above equivalent to lowerlimit < Points < upperlimit , or lowerlimit <= Points <= upperlimit.

I want to write lowerlimit <= Points <= upperlimit, for some query, can anybody help me to clarify the Between keyword, and help me to write my spring data jpa query, thanks in advance

Upvotes: 2

Views: 2652

Answers (2)

ahmetcetin
ahmetcetin

Reputation: 2970

Between keyword works like "lowerlimit <= Points <= upperlimit". Between keyword in Spring Data Jpa is equal to this is Jpql:

… where x.startDate between ?1 and ?2

where Jpql between works with included boundaries. You can also test it by running a repository method using between and see the results. Put 1,2,3 to DB and call it like:

findByPointsBetween(1,2);

Upvotes: 1

Tomas Jacko
Tomas Jacko

Reputation: 390

I think variant lowerlimit <= Points <= upperlimit is true. Because spring-data translate this to JPQL. And JPQL spec use this variant.

Upvotes: 3

Related Questions