So I want only value from the coulmn which is Integer type.
I have this code here as:
In Controller:
@GetMapping("/rating/{id}")
Rating findRating(@PathVariable Integer id) {
Optional<Rating> rating = runRepository.findRating(id);
System.out.println("rating is -------"+rating.get());
return rating.get();
}
In Repository:
public Optional<Rating> findRating(Integer id) {
return jdbcClient.sql
("select rating from movie where id = :id")
.param("id", id).query(Rating.class).optional();
}
The Output is:
rating is ——-Rating[rating=9.0]
The problem with this code is that I will have to trim this value and then I can play around (calculating average etc) with my value 9.0, but I want to make it easier with code. Is there any option?
I tried the above snippet and I expect only the value rather than the coulmn name and value.