I'm writing a Spring Boot app with Spring Data JPA and Kotlin, and I've noticed that in CrudRepository there is the following method:
Optional<T> findById(ID id);
I'm using Kotlin, though, which has much more fluent ways of dealing with nulls than Optional. Does anyone know how I would convert that method to work like this?
fun findById(id: ID): T?
When I extend Repository itself and create a repo with that signature I get the error:
java.lang.ClassCastException: java.util.Optional cannot be cast to com.books.Book