Retrieve (C|B)LOB on SqlRow construction #2267
Merged
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.
Hi Rob,
this PR fixes a possible problem, when selecting a LOB with RawSqlBuilder. The actual data wrapped by e.g. java.sql.Clob is not fetched until explicitely accessed and for that to work, we need an open connection. Since this is not always the case (see testcase) and it depends on the implementation of the JDBC driver to either eagerly or lazily fetch the Clob. H2 for instance seems to directly fetch the data meaning the tests would pass even without this fix, but other drivers don't behave like that.
Note: This somehow breaks the current behaviour. Currently, a call to
row.get("foo")
on a Clob field returns a java.sql.Clob object implemented by the JDBC driver. With the provided implementation a BLOB would return a byte-array and a CLOB a String. Since this also is a "silent" change without breaking compile-time API, this might need some special communicating or version update.All the best
Jonas