Is there a clean way to get a nullable type from a Spring Data repository ? I tried the following code that is not working :
Copy code
class BeerService(val repository : BeerRepository){
fun getBeerById(id : Long) : Beer? {
return repository.findById(id)
}
}
🍺 3
s
sdeleuze
11/14/2018, 10:49 PM
The recommanded approach it to add a custom findByIdOrNull() that returns a nullable value in the repository interface. Also please vote for https://jira.spring.io/browse/DATACMNS-1346.