oracle中大文字量的处理
** oracle中大文字量的处理** 这几天被oracle中的clob字段搞得心烦意乱,在数据库中有字段content,在hibernate中配置文件如下:
<property name="content" type="text" lazy="true">
<column name="CONTENT" />
</property>
使用了ojdbc14.jar这个oracle10G的数据库驱动以后,可以把clob当成string直接操作,但是在hibernate里使用text类型来映射,在pojo类中还是直接使用string. 查了网上很多资料,许多都是要使用流操作来操作clob,这个对于hibernate不好用。 按以上配置好后,在插入数据还是保存,错误如下:
java.sql.SQLException: ORA-01483: DATE 或 NUMBER 赋值变量的长度无效
郁闷了很久,结果最后发现,当插入String字段在1001至2000长度时会报这个错误,当长度不在这个区间就不会出这种问题,现在的办法是把插入字段在1001至2000时,添加空格增加长度,这样就不会报错。 当取出来显示时就用trim就OK了。 ojdbc14.jar可以兼容至oracle8 ,但8需要打补丁。
btw, I tried https://anonsvn.jboss.org/repos/hibernate/core/branches/Branch_3_3_2_GA_CP/testsuite/src/test/java/org/hibernate/test/lob/ClobTest.java
on oracle 10g with private static final int CLOB_SIZE = 1500; and all test pass
and if you could upgrade your hibernate to current developement version (3.5.x, not GA yet), then you can use material_clob to map CLOB to string instead of 'text'
can you guys tell which hibernate version you are using? and if it is possible, would you please fill a bug on hiberante JIRA: http://opensource.atlassian.com/projects/hibernate/secure/Dashboard.jspa, yes, you can assign that to me (stliu)
大哥,我也遇到你这样的问题,单独的这个功能模块解决了,可是整个工程里面这么多啊?