Tuesday, April 10, 2012
Recently I was trying to use Hibernate, JPA annotations and Spring Framework for a new project and trying to use H4 support in the
org.springframework.orm.hibernate4package. A couple of issues caused me some grief:
LocalSessionFactoryBean do not have any way to set a LobHandler as were in the previous hibernate3 version. Then I came across this comment from Juergen as part of https://jira.springsource.org/browse/SPR-9022
We generally rely on the native Hibernate 4 ways of doing things more than before (with Hibernate 3).
So for LOB access, we recommend native Hibernate types (e.g. org.hibernate.type.MaterializedClobType) instead of the former user types that came with Spring's Hibernate 3 support. With Hibernate 4 and modern JDBC drivers (e.g. Oracle 10g or even a JDBC 4 driver), you should not need Spring's LobHandler mechanism at all anymore.
In short, please try to replace your Spring user types with native Hibernate CLOB types. See the Hibernate documentation for details on their support for CLOB access.
Good info. I still need to test the data access code to ensure that the LOBs are correctly handled.
- I have been setting up the Unit test cases to create/drop database schema using the create/drop DatabaseSchema APIs of the
LocalSessionFactoryBean. But in H4, these APIs are removed. Need to find a new way to get this done, may be going directly using the Hibernate APIs. But it makes it a little inconvenient and requires extra framework to handle this in a generic way