use JPA query in your repository interface like this:
@Query(nativeQuery = true, value = "SELECT max(r_id) FROM registrations WHERE r_name LIKE ?1")
int getCount (String name);
when you call this function add modulus(%) with your string like this:
@Autowired
private RegistrationRepository registrationRepository;
@GetMapping(value = "/reg-like")
@ResponseBody
public void regLike() {
int max = registrationRepository.getCount("s%");
System.out.println("" + max);
}
Or you can try something like this:
@Query(nativeQuery = true, value = "SELECT max(r_id) FROM registrations WHERE r_name LIKE %?1")
int getCount (String name);
Then you can omit the modulus(%), when calling the function.
See official documentation here.