To handle Oracle CLOBs and BLOBs within Hibernate, my team has implemented custom user types that leverage temporary LOBs as described in the community area:
http://www.hibernate.org/56.html (CLOBs)
http://www.hibernate.org/73.html (BLOBs)
We are now trying to figure out the best way to free those temporary LOBs in order to prevent any resource leaks. Our tests show that a temporary LOB cannot be freed until the PreparedStatement that inserts the corresponding permanent LOB has executed. This means we have to free the LOBs "sometime later", definitely not within the custom user types.
We're not using JTA, so we cannot adopt the strategy described in the community area for freeing temporary LOBs (hook into the JTA transaction manager):
http://www.hibernate.org/56.74.html
(This thread mentions that Hibernate will eventually acquire "proper event handling" -- where can I find out more about this?)
Does Hibernate provide hooks so that, for instance, we could free temporary LOBs right before a session is flushed or a transaction is committed/rolled back? We've considered implementing an Interceptor that frees temporary LOBs in the postFlush method, but this doesn't appear to be an intended use of that mechanism.
Any help is much appreciated!
- nate
p.s. Does anyone have specifics on which resources temporary LOBs hold on to? I'm not clean whether these are JVM resources, database resources, or both.