Okay, I feel pretty silly. As it turns out, even this simple code was storing the CLOB
correctly:
jdbcTemplate.update("UPDATE my_table SET title = ?, content = ? WHERE id = ?", getTitle(), getContentString(), getId());
The issue was my code that retrieved the CLOB
back from the database. The following is my speculation based on my code (and the fix): it seems as though smaller CLOB
's get cached in memory, and can be read at a later time (namely, after the connection is closed, they can still be read). However, for larger CLOB
's, they must be read while the connection is still open.
For me, this meant the fix was as simple as reading the CLOB
's contents as soon as it was available to my object. In my case, I'm not really worried about memory issues, because I don't expect that my CLOB
's will contain inordinately sized contents, and so reading the value into memory immediately is an acceptable approach.