spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
753 stars 345 forks source link

Querying by 'Example' uses the datatype of the entity field, rather than the type as defined in the Converter. #1712

Closed seismic83 closed 8 months ago

seismic83 commented 8 months ago

If I issue a findBy(Example.of(_myExampleInstance_), it fails with "ORA-01722: invalid number" because of a type difference between the Java Type and the database type, even though my converter is being applied.

Looking at the trace logs from the StatementCreatorUtils, for the first parameter you can see that the converter was applied, in this case the field type is Boolean and my converter converts it to a String with a value of 'N'. However, the SQL type used is incorrect.

Setting SQL statement parameter value: column index 1, parameter value [N], value class [java.lang.String], SQL type -7 Setting SQL statement parameter value: column index 2, parameter value [88594231], value class [java.lang.Long], SQL type -5

I would've expected the finder to use the Datatype of the registered converter and not the type of the field defined in the Example instance.

seismic83 commented 8 months ago

Using JdbcValue in the converter addresses the issue directly.