Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate4 & Lobhandler

According to this post i changed my session factory definition from

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" 
    p:dataSource-ref="dataSource" p:lobHandler-ref="oracleLobHandler">
    <property name="annotatedClasses">
    <list>
        [..]

into

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
    p:dataSource-ref="dataSource">
    <property name="annotatedClasses">
    <list>
        [..]

Unfortunately there is no possibility to define the LobHandler as it was in hibernate3. As there is still the following written in the "Lobhandler"s javadoc it seems still necessary

Summarizing the recommended options (for actual LOB fields):

  • JDBC 4.0 driver: DefaultLobHandler with streamAsLob=true.

  • PostgreSQL: DefaultLobHandler with wrapAsLob=true. Oracle 9i/10g:

  • OracleLobHandler with a connection-pool-specific NativeJdbcExtractor.

  • For all other database drivers (and for non-LOB fields that might potentially turn into LOBs on some databases): a plain DefaultLobHandler.

So, is it still necessary to define the lobHandler in hibernate4 or not??? And if so, where can I define it?

like image 490
Hons Avatar asked Nov 14 '22 12:11

Hons


1 Answers

It seems like you don't need it. They recommend using the native types as opposed to user types.

See http://www.sureshpw.com/2012/04/spring-hibernate-4.html.

like image 96
bdetweiler Avatar answered Dec 15 '22 00:12

bdetweiler