And in BinaryBlobType/StringClobType, add register at the
end of nullSafeSet(...)
<code>
public void nullSafeSet(PreparedStatement st,
Object value, int index)
throws HibernateException, SQLException {
if (value == null) {
st.setClob(index, null);
return;
}
if (isOraclePreparedStatement(st)) {
// skip ...
// open temperary clob and write....
// skip ...
temperaryClob.close();
LobCleanUpInterceptor.registerTempLobs(temperaryClob);
} else {
st.setClob(index,
Hibernate.createClob((String) value));
}
}
</code>
finally, obtain session with interceptor
sessionFactory.openSession(new LobCleanUpInterceptor());
After flush() or commit(), nullSafeSet(...) will be called
and register temperary LOBs into a thread local set.
when flush() is complete. postFlush(...) will be invoked and
all registered temperary LOBs will be cleaned.
This interceptor may only work when applying
thread-local-session pattern.
regards. |