Thread:
 Free temperary clob/blob with interceptor (1) 
 ingramchen   12 Sep 2004, 10:36 
 Re: Free temperary clob/blob with interceptor (... 
 ingramchen   12 Sep 2004, 10:37 
 Problem with interceptor approach. 
 rajwani   03 Mar 2005, 11:38 
 Re: Problem with interceptor approach. 
 rajwani   03 Mar 2005, 16:08 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: ingramchen (12 Sep 2004, 10:37) Replies: 2, Views: 38807
Subject: Re: Free temperary clob/blob with interceptor (2) (cont...
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.
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]