fix: EXPOSED-382 ClassCastException when uuid().references() is used with EntityID column #2079
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since version 0.50.0, using
Column.references()
invoked on aUUIDColumnType
that targets anEntityIDColumnType<UUID>
causes aClassCastException
.This occurs because
PreparedStatementApi.fillParameters()
tries to get thevalueToDB()
fromEntityIDColumnType
rather than the underlyingUUIDColumnType
.This exception does not happen with Int- or LongColumnType because their EntityID variants are wrapped as
AutoIncColumnType
that delegates to the correct underlying type.And this also doesn't happen if
reference()
is used instead because it creates anEntityIDColumnType
under-the-hood which avoids any type mismatch.This was likely quietly happening before but only causes an issue now that a stricter column type-safety has been introduced.
Note: I considered adding similar logic to
OptionalReference.getValue()
, but there is no optional variant forColumn.references()
, so this point should not be reached.