? Spring+Hibernate不能保存clob字段
我的配置如下:
applicationContext.xml
<!-- 使用spring+hibernate处理oracle BLOB-->
<bean id= "nativeJdbcExtractor "
class= "org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor " />
<bean id= "oracleLobHandler "
class= "org.springframework.jdbc.support.lob.OracleLobHandler "
lazy-init= "true ">
<property name= "nativeJdbcExtractor ">
<ref bean= "nativeJdbcExtractor " />
</property>
</bean>
sessionFactory也加了这个属性
<property name= "lobHandler ">
<ref bean= "oracleLobHandler " />
</property>
对应的hbm.xml里面对应的配置:
<property name= "ggnr " type= "org.springframework.orm.hibernate3.support.ClobStringType ">
<column name= "GGNR " /> <!--GGNR 表示公告的内容-->
</property>
对应的form为:private String ggnr;
主程序:
/*
* 发布新公告
*/
public boolean addGgxx(HttpSession session, EditGgxxForm editGgxxForm) {
String title = (String) editGgxxForm.getGgzt();
String nr = (String) editGgxxForm.getGgnr();
Date date = new Date();
CgGgxx ggxx = new CgGgxx();
ggxx.setGgnr(nr);
ggxx.setGgzt(title);
ggxx.setFbr((String) session.getAttribute( "user "));
ggxx.setFbrq(date);
return ggxxDao.add(ggxx);
}
/**
* 公告模块的功能实现
* @author WMF
*
*/
public class GgxxDao extends HibernateDaoSupport {
/*
* 发布新公告
*/
public boolean add(CgGgxx ggxx) {
try {
this.getHibernateTemplate().save(ggxx);
this.getHibernateTemplate().flush();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
}
发布新公告的时候老是抛以下异常,请各位指教:
16:54:30,078 DEBUG SessionImpl:219 - opened session at timestamp: 4837513912639488
16:54:30,078 DEBUG DefaultSaveOrUpdateEventListener:161 - saving transient instance
16:54:30,078 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 1)
16:54:30,078 DEBUG ConnectionManager:415 - opening JDBC connection
16:54:30,078 DEBUG SQL:346 - select GGXX_SEQ.nextval from dual
16:54:30,093 DEBUG AbstractBatcher:424 - preparing statement
16:54:30,093 DEBUG SequenceGenerator:82 - Sequence identifier generated: 98
16:54:30,093 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 2)
16:54:30,140 DEBUG AbstractBatcher:470 - closing statement
16:5