clob字段只能写入4k内容,超过后报null at org.apache.openjpa.jdbc.sql.OracleDictionary.putString
来源:互联网 发布:比特彗星端口开放 编辑:程序博客网 时间:2024/05/22 03:42
项目架构是Spring 2.5 + openjpa 1.1, oracle 10g
在一个clob字段写入超过4k文字时报异常
[11:14:55.257] {http--8080-1} <openjpa-1.1.0-r422266:657916 fatal store error> org.apache.openjpa.persistence.RollbackEx
ception: The transaction has been rolled back. See the nested exceptions for details on the errors that occurred.
[11:14:55.257] {http--8080-1} at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:523)
[11:14:55.257] {http--8080-1} at _jsp._test__jsp._jspService(_test__jsp.java:86)
[11:14:55.257] {http--8080-1} at com.caucho.jsp.JavaPage.service(JavaPage.java:61)
[11:14:55.257] {http--8080-1} at com.caucho.jsp.Page.pageservice(Page.java:587)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.PageFilterChain.doFilter(PageFilterChain.java:192)
[11:14:55.257] {http--8080-1} at cn.pconline.common.monitor.MonitorFilter.doFilter(MonitorFilter.java:88)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[11:14:55.257] {http--8080-1} at projects.common.filter.HtmlReduceFilter.doFilter(HtmlReduceFilter.java:29)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[11:14:55.257] {http--8080-1} at com.caucho.filters.GzipFilter.doFilter(GzipFilter.java:155)
[11:14:55.257] {http--8080-1} at projects.common.filter.GzipFilter.doFilter(GzipFilter.java:19)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[11:14:55.257] {http--8080-1} at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(Op
enEntityManagerInViewFilter.java:112)
[11:14:55.257] {http--8080-1} at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.jav
a:76)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.FilterFilterChain.doFilter(FilterFilterChain.java:87)
[11:14:55.257] {http--8080-1} at com.caucho.server.cache.CacheFilterChain.doFilter(CacheFilterChain.java:175)
[11:14:55.257] {http--8080-1} at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181)
[11:14:55.257] {http--8080-1} at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266)
[11:14:55.257] {http--8080-1} at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:268)
[11:14:55.257] {http--8080-1} at com.caucho.server.port.TcpConnection.run(TcpConnection.java:602)
[11:14:55.257] {http--8080-1} at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:690)
[11:14:55.257] {http--8080-1} at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:612)
[11:14:55.257] {http--8080-1} at java.lang.Thread.run(Thread.java:619)
[11:14:55.257] {http--8080-1} Caused by: <openjpa-1.1.0-r422266:657916 fatal general error> org.apache.openjpa.persisten
ce.PersistenceException: The transaction has been rolled back. See the nested exceptions for details on the errors that
occurred.
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2160)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2007)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1905)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1823)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1347)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:877)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:512)
[11:14:55.257] {http--8080-1} ... 22 more
[11:14:55.257] {http--8080-1} Caused by: <openjpa-1.1.0-r422266:657916 nonfatal general error> org.apache.openjpa.persis
tence.PersistenceException: null
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.sql.OracleDictionary.putString(OracleDictionary.java:956)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedClobFieldStrategy.putData(MaxEmbeddedC
lobFieldStrategy.java:70)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedLobFieldStrategy.customUpdate(MaxEmbed
dedLobFieldStrategy.java:162)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.meta.strats.MaxEmbeddedLobFieldStrategy.customInsert(MaxEmbed
dedLobFieldStrategy.java:140)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.meta.FieldMapping.customInsert(FieldMapping.java:684)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager$CustomMapping.execute(AbstractUp
dateManager.java:358)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java
:94)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(AbstractUpdateManager.java
:72)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(JDBCStoreManager.java:549)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:13
0)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.datacache.DataCacheStoreManager.flush(DataCacheStoreManager.java:5
54)
[11:14:55.257] {http--8080-1} at org.apache.openjpa.kernel.DelegatingStoreManager.flush(DelegatingStoreManager.java:13
0)
[11:14:55.257] {http--8080-1} ... 29 more
[11:14:55.257] {http--8080-1} Caused by: java.lang.NullPointerException
[11:14:55.257] {http--8080-1} at org.apache.openjpa.jdbc.sql.OracleDictionary.putString(OracleDictionary.java:953)
[11:14:55.257] {http--8080-1} ... 40 more
实体类代码片段:
看上去好像没问题, 看了openjpa报错部分的源码, 也没能定位到原因
然后打印出sql和去掉注解后的sql对比, 发现有区别.
出错的sql:
INSERT INTO test_clob (id, content, version)
VALUES (?, ?, ?)
[params=(int) 10, (Reader) java.io.StringReader@5a82b2, (int) 1]
去掉注解后的sql:
INSERT INTO test_clob (id, content, version)
VALUES (?, ?, ?)
[params=(int) 12, (String) 我再测字数我再测字数我再测字数我再测字数我再测字数我再测字数我再测字数我再测字数我再测字数我
再测字数我再测字数我再测字数我再测字数我再测..., (int) 1]
去掉nullable = false后的sql:
INSERT INTO test_clob (id, content, version)
VALUES (?, ?, ?)
[params=(int) 11, (Clob) oracle.sql.CLOB@11bfcfc, (int) 1]
显然,问题找到了, 当@Clob标签碰到nullable = false属性后,发生化学反应,蓝色是正确的,红色是错误代码
问题是找到了,如果用@Clob标签就别再加nullable属性,但是原因还是不知道...
- clob字段只能写入4k内容,超过后报null at org.apache.openjpa.jdbc.sql.OracleDictionary.putString
- JDBC从文件中读取内容写入CLOB字段的例子
- spring更新clob报错:org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL
- oracle CLOB类型超过4000个字段sql插入方法
- JDBC读取clob字段
- JDBC更新CLOB字段
- openjpa实体类中大数据集(oracle clob)的字段处理
- 查看clob字段内容
- 如何解决 tomcat 下 oracle 缓冲池 读取 clob 字段内容 时的错误 "java.lang.ClassCastException: org.apache.commons.dbcp.DelegatingResultSet "
- JDBC操作Clob,Blob字段
- java-JDBC插入Clob字段
- JDBC 处理Oracle Clob字段
- JDBC 判断 NULL 字段
- java操作将字符串写入clob字段
- JAVA读取、写入、更新CLOB字段
- JAVA读取、写入、更新CLOB字段
- 【Oracle】Clob字段读取,写入,更新
- Oracle 判断CLOB字段是否为null
- http://10.1.1.35/ule_exec/exec05_raid.txt
- http://10.1.1.35/ule_exec/exec06_postfix.txt
- http://10.1.1.35/ule_exec/exec07_clamav_postfixadmin.txt
- http://10.1.1.35/ule_exec/exec08_nis.txt
- IT工作者应该知道的10个小秘密
- clob字段只能写入4k内容,超过后报null at org.apache.openjpa.jdbc.sql.OracleDictionary.putString
- C#使用反射调用SpVoice实现播放文本
- 关于cs/bs/n层架构
- 蛇形填数——很白痴的题,我热身用
- 为什么中国企业普遍认为程序员是吃青春饭的
- C++读写复合文档的一点补充
- 总结下C++下的单元测试
- can收发程序分析
- linux内核学习笔记之——list_for_each_entry