For those not in the know:
- Oracle LOBs are implemented like crap and, instead of using the standard interface suggested by JDBC (coughlike everyone elsecough) obliges to use their proprietary classes, something that inspired pages like this one on the hibernate wiki.
- Weblogic (and other app servers) wraps your JDBC connection with their own when using a Connection Pool.
Other frameworks like p6spy and commons-dbcp may wrap Connections, creating a beautiful onion of library dependencies for contemplative rejoyce. Before implementing your own Hibernate type mapping, there is a better option provided by Spring: a separation of concepts into two classes that can be injected into the LocalSessionFactory.
LobHandler: the class that handles all the LOB stuff, and
- NativeJdbcExtractor: responsible for the onion peeling. Since the extractor is only needed inside the app server, a new separate configuration would be handy for the testsuite:
Now you only have to combine a set of config files for testing or deployment. Order is not important.
One last note: if working with weblogic, be sure to uncheck "Remove Infected Connections Enabled" on your Connection Pool since it would disable connection reuse.