Thread:
 summary... 
 Lukasz (Qr)   29 Sep 2004, 16:04 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: Lukasz (Qr) (29 Sep 2004, 16:04) Replies: 0, Views: 38252
Subject: summary...
After doing some research and trying to use it, the code for 
StringClobType requires some changes. I hope that this will save 
someone some time and digging through all the different threads.

1) readline issue:
Just do not use readline() - (check: rgodfrey's post)
<code>
	        StringBuffer sb = new StringBuffer(); 
	        try { 
	            char[] charbuf = new char[4096]; 
	            for (int i = clobReader.read(charbuf); i > 0; i = 
clobReader.read(charbuf)) { 
	                sb.append(charbuf, 0, i); 
	            } 
	        } catch (IOException e) { 
	            throw new SQLException(e.getMessage()); 
	        } 
	        return sb.toString(); 
</code>
on the other hand why shouldn't we just as something simple as:
<code>
    public Object nullSafeGet(ResultSet rs, String[] names, Object 
owner)
            throws SQLException {
        Clob clob = rs.getClob(names[0]);
        return (clob==null? null :clob.getSubString(1, (int) 
clob.length()));
    }
</code>
it works fine for me (Oracle 8i with Oracle 9i drivers)

2) obtain base connection, not the dbcp wrapper:
Connection conn = st.getConnection();
should be changed to:
Connection conn = ps.getConnection().getMetaData().getConnection();
(check: Paul Branscombe's post)

3) freeTemporary lob 
check ingramchen's both posts - "Free temperary clob/blob with 
interceptor (1)"
Great job ingramchen!

I would use reflection to avoid a compile-time dependency on the 
Oracle driver. To do so change:
<code>
                cleanIfBLOB(lob);
                cleanIfCLOB(lob);
</code>
to:
<code>
    			Method freeTemporary = lob.getClass
().getMethod("freeTemporary", new Class[0]);
    			freeTemporary.invoke(lob, new Object[0]);
</code>

and finally tip 'how to set interceptor' for those who would like to 
use springframework.orm.hibernate&#8217;s 
org.springframework.orm.hibernate.LocalSessionFactoryBean
just
lsfb.setEntityInterceptor(new LobCleanUpInterceptor());
or even better user xml equivalent.

Thanks all.

Lukasz
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]