Description
Query methods in repositories such as findByAvailableIsTrue()
are converted to SQL statements with where parts like ("SOME_TABLE"."AVAILABLE" = TRUE)
. This is fine for many databases, but Oracle has no boolean type and people typically use the type NUMBER(1)
instead. In such a case, the predicate should correctly translate to ("SOME_TABLE"."AVAILABLE" = 1)
.
The reason for this erroneous translation is located in org.springframework.data.relational.core.sql.render.ExpressionVisitor
, which in our case calls the toString()
method of the org.springframework.data.relational.core.sql.BooleanLiteral
to compute the value of the expression (TRUE
), despite the fact that the documentation of the toString()
method of the org.springframework.data.relational.core.sql.Segment
interface (which BooleanLiteral
implements) explicitly states that
While it might work in the context of a specific dialect, you should not that the toString() representation works across multiple databases. (sic)
A possible solution would be to extend org.springframework.data.relational.core.dialect.Dialect
with a
BooleanComparison booleanComparison()
method that would then be implemented in OracleDialect
.