5

根据这篇文章,我将会话工厂定义从

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

进入

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

不幸的是,不可能像在 hibernate3 中那样定义 LobHandler。由于“Lobhandler”的javadoc中仍然写有以下内容,因此似乎仍然有必要

总结推荐的选项(对于实际的 LOB 字段):

  • JDBC 4.0 驱动程序:StreamAsLob=true 的 DefaultLobHandler。

  • PostgreSQL:带有 wrapAsLob=true 的 DefaultLobHandler。甲骨文 9i/10g:

  • OracleLobHandler 具有特定于连接池的 NativeJdbcExtractor。

  • 对于所有其他数据库驱动程序(以及对于可能在某些数据库上变成 LOB 的非 LOB 字段):一个普通的 DefaultLobHandler。

那么,是否还需要在hibernate4中定义lobHandler???如果是这样,我在哪里可以定义它?

4

1 回答 1

1

好像你不需要它。他们建议使用本机类型而不是用户类型。

请参阅http://www.sureshpw.com/2012/04/spring-hibernate-4.html

于 2016-08-13T19:25:20.160 回答