-
Notifications
You must be signed in to change notification settings - Fork 699
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
SpelEvaluatorto gatherTypeInformationusingExpression::getValueTypeDescriptor - introduced a version of
evaluatethat 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
StringBasedJdbcQueryto use the new method fromSpelEvaluator - passed values and
TypeInformationthroughconvertAndAddParameterinstead of adding directly to theMapSqlParameterSource
- patched
How should I proceed to send the PRs, since they involve two projects?
Metadata
Metadata
Assignees
Labels
type: bugA general bugA general bug