I 'fixed' the problem of getting extra crap returned on some of my clobs. A hack but it works.
In my mapping file I have:
<property name="extraData" type="text" column="extra_data" not-null="true">
now I added a new property:
<property name="dataLength" type="int" formula="length(extra_data)"/>
In my POJO when setExtraData(String extraData) is called,
I substring it to the dataLength.
if (getDataLength() != null) {
extraData = extraData.substring(0, getDataLength());
}
since dataLength might not be set yet, I do the same thing in setDataLength
if (getExtraData() != null) {
extraData = extraData.substring(0, getDataLength());
}
(More or less, I'm actually using a generated base class, and mapping it to a derived class which I use to make sure data is encrypted/decrypted goin g in and out of the database. So my own code is a bit more complicated, but the above is the gist of what I'm doing.)
Anyway using the 'computed' dataLength property and trimming the clob field to that value is going to be 'good enough' until I can talk people into upgrading to 3.2.
Hope this helps someone else.
|