clob 8月5日
package com.m;
import java.io.Writer;
import org.hibernate.Hibernate;
import org.hibernate.lob.SerializableClob;
import com.m.database.dao.bean.DbUtils;
import com.m.model.po.ACREPLY;
public class TestClob {
?public boolean insertClob() {
??ACREPLY ac = new ACREPLY();
??try {
???ac.setActiv_id(new Long(12));
???ac.setAreply_id(new Long(23));
???ac.setReply_content(Hibernate.createClob(" "));
???DbUtils.getDao().insert(ac);
???String content = "aaaaaaaaaaaaaaa";
???SerializableClob sclob = (SerializableClob) ac.getReply_content();
???java.sql.Clob jclob = sclob.getWrappedClob();
?
???oracle.sql.CLOB clob = (oracle.sql.CLOB) jclob;
?
???Writer out = clob.getCharacterOutputStream();
???out.write(content);
???out.close();
??} catch (Exception e) {
???// TODO Auto-generated catch block
???e.printStackTrace();
??}
??return false;
?}
?public static void main(String[] agrs) {
??TestClob tc = new TestClob();
??tc.insertClob();
?}
}
到oracle.sql.CLOB clob = (oracle.sql.CLOB) jclob;步的时候出现了
org.hibernate.lob.ClobImpl cannot be cast to oracle.sql.CLOB
?at com.mender.TestClob.insertClob(TestClob.java:28)
?at com.mender.TestClob.main(TestClob.java:45)错误