I'm trying to use SpEL to bind parameter values from DTOs like this, in a JDBC repository:
@Query(" ........ :#{#route.timestamp} .......")
fun updateRoute(driverId: UUID, route: Route): Instant?
When any property is null, an NPE is thown in org.springframework.data.repository.query.SpelEvaluator because it uses Collectors.toMap and it doesn't support null values.
Also, there is no convertion to database types, for example an Instant value isn't converted to java.sql.Timestamp and sql execution fails.
I managed to fix both issues locally (I think):
- In
spring-data-commons
- patched
SpelEvaluator to gather TypeInformation using Expression::getValueTypeDescriptor
- introduced a version of
evaluate that returns a vo with both value and TypeInformation
- got rid of the NPE by doing the collection manually instead of using
Collectors.toMap
- In
spring-data-jdbc:
- patched
StringBasedJdbcQuery to use the new method from SpelEvaluator
- passed values and
TypeInformation through convertAndAddParameter instead of adding directly to the MapSqlParameterSource
How should I proceed to send the PRs, since they involve two projects?