Thread:
 Temporary Clob Resource Leak 
 rgodfrey   10 Oct 2003, 16:05 
 Re: Temporary Clob Resource Leak 
 rgodfrey   14 Oct 2003, 13:07 
 Re: Temporary Clob Resource Leak 
 bd   07 Nov 2003, 11:36 
 Re: Temporary Clob Resource Leak 
 yvanhess   05 Dec 2003, 16:21 
 Re: Temporary Clob Resource Leak 
 bd   13 Dec 2003, 16:17 
 Re: Temporary Clob Resource Leak 
 bd   17 Dec 2003, 10:49 
 Re: Temporary Clob Resource Leak 
 neil_g_avery   07 Jan 2004, 11:03 
 Re: Temporary Clob Resource Lea... 
 bd   30 Jan 2004, 14:43 
 Re: Temporary Clob Resource ... 
 Kai   02 Mar 2004, 17:22 
 Re: Temporary Clob Resour... 
 hypernate   11 Mar 2004, 22:34 
 Re: Temporary Clob Reso... 
 telebears   08 Dec 2004, 19:05 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: bd (13 Dec 2003, 16:17) Replies: 6, Views: 39016
Subject: Re: Temporary Clob Resource Leak
On 05 Dec 2003 16:21, yvanhess wrote:

>We also use the Oracle CLOB custom type solution in our application.
>Can you explain more in detail the solution/the pattern to solve the
>resource leak problem.

It's simple, but making it work in your environment might not be. You
need to execute this statement after you're done with the CLOB: 
---
oracle.sql.CLOB.freeTemporary(temporaryClob);
---

I wanted to make this non-intrusive, so that user of the CLOB mapper
would not need to manually code the release (which would render mapper
useless). So I hooked cleanup code to a transaction listener and hooked
the listener to the UserTransaction. If you're not using JTA, you will
have to find some other hook. It will be all much easier when Hibernate
gets proper event handling.

Code illustration:
---
Context ctx = new InitialContext();
Transaction t =
((TransactionManager)ctx.lookup("java:comp/UserTransaction")).getTransaction()
t.registerSynchronization(new Synchronization()
{
  public void beforeCompletion()
  {
// temporaryClob is the temp. CLOB created by the mapper. Variable must 
// of course be final for this to work and in scope.
    oracle.sql.CLOB.freeTemporary(temporaryClob);
  }
  public void afterCompletion(int i)
  {
    // nothing to do here
  }
});
---
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]