Closed
Description
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 gatherTypeInformation
usingExpression::getValueTypeDescriptor
- introduced a version of
evaluate
that returns a vo with both value andTypeInformation
- got rid of the NPE by doing the collection manually instead of using
Collectors.toMap
- patched
- In
spring-data-jdbc
:- patched
StringBasedJdbcQuery
to use the new method fromSpelEvaluator
- passed values and
TypeInformation
throughconvertAndAddParameter
instead of adding directly to theMapSqlParameterSource
- patched
How should I proceed to send the PRs, since they involve two projects?