Oracle Clob Reader问题:违反协议

时间:2014-04-01 11:54:39

标签: hibernate clob ojdbc

我使用java7,jboss7,ojdbc7,hibernate 4。 Table有一个CLOB列,在域类中,代码是这样的:

@Lob private String MyClob;

我在查询时遇到这个奇怪的错误,这不一致。

Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: IOException occurred reading text
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387)
        at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1310)
        at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:273)
        at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getResultList(CriteriaQueryCompiler.java:254)
        ...
        ... 102 more
Caused by: org.hibernate.HibernateException: IOException occurred reading text
        at org.hibernate.type.descriptor.java.DataHelper.extractString(DataHelper.java:94)
        at org.hibernate.type.descriptor.java.DataHelper.extractString(DataHelper.java:280)
        at org.hibernate.type.descriptor.java.StringTypeDescriptor.wrap(StringTypeDescriptor.java:89)
        at org.hibernate.type.descriptor.java.StringTypeDescriptor.wrap(StringTypeDescriptor.java:39)
        at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$1.doExtract(ClobTypeDescriptor.java:60)
        at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:261)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:257)
        at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:247)
        at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:332)
        at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2912)
        at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1672)
        at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1604)
        at org.hibernate.loader.Loader.getRow(Loader.java:1504)
        at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:712)
        at org.hibernate.loader.Loader.processResultSet(Loader.java:942)
        at org.hibernate.loader.Loader.doQuery(Loader.java:910)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
        at org.hibernate.loader.Loader.doList(Loader.java:2522)
        at org.hibernate.loader.Loader.doList(Loader.java:2508)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2338)
        at org.hibernate.loader.Loader.list(Loader.java:2333)
        at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490)
        at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
        at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
        at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1269)
        at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
        at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:264)
        ... 104 more
Caused by: java.io.IOException: Protocol violation: [ 14, 47, ]
        at oracle.jdbc.driver.OracleClobReader.needChars(OracleClobReader.java:264)
        at oracle.jdbc.driver.OracleClobReader.read(OracleClobReader.java:195)
        at org.hibernate.type.descriptor.java.DataHelper.extractString(DataHelper.java:86)
        ... 131 more
Caused by: java.sql.SQLException: Protocol violation: [ 14, 47, ]
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:669)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
        at oracle.jdbc.driver.T4C8TTIClob.read(T4C8TTIClob.java:245)
        at oracle.jdbc.driver.T4CConnection.getChars(T4CConnection.java:3901)
        at oracle.sql.CLOB.getChars(CLOB.java:517)
        at oracle.jdbc.driver.OracleClobReader.needChars(OracleClobReader.java:245)

1 个答案:

答案 0 :(得分:6)

ojdbc7 jar的问题。 如果clob的长度为4193个字符,则驱动程序无法检索。 使用新的OJDBC7补丁罐