1

我有一个实体,其中一个字段映射到 CLOB:

// Entity variable
@Lob
private String payload;


-- DDL
CREATE TABLE "MYENTITY" (
    "PAYLOAD" CLOB,
     ... 
);

在使用 Hibernate 持久化此实体时,它适用于小字符串 (<1MB),但超过 1MB 的字符串不起作用。DB2 抱怨该值太大(SQLCODE=-302,SQLSTATE=22001),但据我所知,CLOB 可能是 2GB 左右。我没有在列上定义任何长度限制。

问题: 我在这里缺少什么?是否有任何长度限制或最大尺寸字段我看不透?

我很感谢任何导致解决此问题的线索。

DB:IBM DB2 9.7 LUW JPA:休眠 3.3.2

堆栈跟踪:

  org.hibernate.exception.DataException: could not insert: [com.example.MyEntity]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:100) 
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) 
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64) 
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2176) 
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2656) 
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71) 
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279) 
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321) 
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204) 
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130) 
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:49)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:154) 
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:110)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61) 
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:646) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:620) 
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:624)
at 

org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:220) 
    ... 110 common frames omitted
Caused by: com.ibm.db2.jcc.am.eo: DB2 SQL Error: SQLCODE=-302, SQLSTATE=22001, SQLERRMC=null, DRIVER=4.7.85
    at com.ibm.db2.jcc.am.dd.a(dd.java:668) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.dd.a(dd.java:60) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.dd.a(dd.java:127) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.nm.c(nm.java:2493) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.nm.a(nm.java:1977) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.t4.db.n(db.java:801) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.t4.db.i(db.java:258) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.t4.db.c(db.java:53) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.t4.t.c(t.java:44) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.t4.sb.i(sb.java:147) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.nm.ib(nm.java:1972) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.om.b(om.java:3553) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.om.Yb(om.java:710) ~[db2jcc4.jar:na]
    at com.ibm.db2.jcc.am.om.executeUpdate(om.java:689) ~[db2jcc4.jar:na]
    at org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94) 
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
4

1 回答 1

3

默认 LOB 列大小为 1 MB。如果您需要更大的列,请指定大小:

-- DDL
CREATE TABLE "MYENTITY" (
    "PAYLOAD" CLOB (2 G),
     ... 
);
于 2013-06-11T16:40:25.033 回答