1.使用了10G提供的驱动OJDBC14.JAR。 
2.HIBERNATE设置了< property name="hibernate.connection.SetBigStringTryClob">true</ property>。 
3.映射文件 列类型 写的 "text"。 
<!-- 集成hibernate配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties" ref="hibernateProperties"></property>
<property name="mappingResources">
<list>
<value>cn/sjlr/domain/Account.hbm.xml</value>
<value>cn/sjlr/domain/BulletinIndex.hbm.xml</value>
<value>cn/sjlr/domain/BulletinContent.hbm.xml</value>
</list>
</property>
</bean>
<bean name="hibernateProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
<prop key="hibernate.connection.SetBigStringTryClob">true</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
</props>
</property>
</bean>
查询报错  FOUND CLOB EXPECTED LONG。 
保存同样错误。 网上搜索出来有说可以的,有说仅能保存不能查询的,特来请教一下。 

解决方案 »

  1.   

    映射类型改成spring的org.springframework.orm.hibernate.support.ClobStringType也不行。
      

  2.   

    映射类型改成spring的org.springframework.orm.hibernate.support.ClobStringType<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.Oraclelobhandler">
            <property name="nativeJdbcExtractor"><ref local="nativeJdbcExtractor"/></property>
        </bean><bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor">
        </bean>都有了吗。应该没问题
      

  3.   

    这是SPRING提供的类,但是新的10G JDBC驱动不是可以支持CLOB直接映射为STRING了吗?搜索出来还贴了例子,不过我是保存于查询都没有成功。先试试SPRING的方法吧,谢谢。
      

  4.   

    还是不行,报错
     org.hibernate.MappingException: Could not determine type for: org.springframework.orm.hibernate.support.ClobStringType
      

  5.   

    改为使用SPRING支持LOB的方法,报错org.hibernate.MappingException: Unknown entity: BulletinContent
    at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:701)
    at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:92)
    at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
    at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997)
    at cn.sjlr.dao.impl.BulletinDaoImpl.findContentById(BulletinDaoImpl.java:32)
    at cn.sjlr.service.BulletinService.findContentById(BulletinService.java:30)
    at cn.sjlr.service.BulletinService$$FastClassByCGLIB$$24c22387.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
    at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:692)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:108)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:625)
    at cn.sjlr.service.BulletinService$$EnhancerByCGLIB$$dd5d9493.findContentById(<generated>)
    at cn.junit.BulletinTest.test(BulletinTest.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor">
       </bean>
    <bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
       <property name="nativeJdbcExtractor"><ref local="nativeJdbcExtractor"/></property>
       </bean>  <!-- 集成hibernate配置 --> 
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties" ref="hibernateProperties"></property>
    <property name="lobHandler">
    <ref bean="oracleLobHandler"/>
    </property>
    <property name="mappingResources">
    <list>
    <value>cn/sjlr/domain/Account.hbm.xml</value>
    <value>cn/sjlr/domain/BulletinIndex.hbm.xml</value>
    <value>cn/sjlr/domain/BulletinContent.hbm.xml</value>
    </list>
    </property>
    </bean>实体类 BulletinContent,映射BulletinContent.hbm.xml
    @Override
    public BulletinContent findContentById(String id){
    return (BulletinContent) sessionFactory.getCurrentSession().get("BulletinContent", id);
    }这是Dao查询代码。