JPA @Query with Complex nullable object
I'm building a repository with a getAll query that uses a complex type parameter to filter, like:
@Query("""
SELECT c FROM City c
WHERE :filter IS NULL OR c.code LIKE %:#{#filter.code}%
""")
fun getAllCitiesFiltered(@Param("filter") filter: MyFilter?) : List
The MyFilter class is a simple POJO:
class MyFilter {
var code: String? = null
var description: String? = null
}
At some point in my code I call getAllCitiesFiltered(filter) and this filter may be null or may...