Spring Data JPA provides a number of keywords to express conditional queries for this purpose, roughly as follows:
and---are equivalent to the AND keyword in SQL, such as Findbyusernameandpassword (String user, Striang pwd);
The or---is equivalent to the OR keyword in SQL, such as findbyusernameoraddress (string user, String addr);
The between---is equivalent to the between keyword in SQL, such as Findbysalarybetween (int max, int min);
The LessThan---is equivalent to "<" in SQL, such as Findbysalarylessthan (int max);
GreaterThan---is equivalent to ">" in SQL, such as Findbysalarygreaterthan (int min);
IsNull---is equivalent to "is null" in SQL, such as Findbyusernameisnull ();
Isnotnull---is equivalent to "is not NULL" in SQL, such as Findbyusernameisnotnull ();
Notnull---and isnotnull equivalence;
The like---is equivalent to the "as" in SQL, such as Findbyusernamelike (String user);
The notlike---is equivalent to "not like" in SQL, such as Findbyusernamenotlike (String user);
The order-by---is equivalent to the "FINDBYUSERNAMEORDERBYSALARYASC" in SQL, such as the String user;
The not---is equivalent to "in SQL"! = ", such as Findbyusernamenot (String user);
In---is equivalent to ' in ' in SQL, such as Findbyusernamein (Collection<string> userlist), the parameter of the method can be either a Collection type or an array or an indefinite length parameter;
The notin---is equivalent to "not in" SQL, such as Findbyusernamenotin (Collection<string> userlist), which can be either a Collection type or an array or not Fixed length parameters;
Keywords for Spring Data JPA conditional query