hibernate 插入 Clob 问题,求助
代码如下:
public void save(News news) {
//this.getHibernateTemplate().saveOrUpdate(news);
SessionFactory sessionFactory = getHibernateTemplate().getSessionFactory();
Session session = sessionFactory.openSession();
Transaction tt = session.beginTransaction();
try{
news.setContent(Hibernate.createClob(" "));
Serializable result = session.save(news);
session.flush();
session.refresh(news, LockMode.UPGRADE);
int intId = news.getId().intValue();
String contentStr = news.getContentStr();
oracle.sql.CLOB content = (oracle.sql.CLOB)news.getContent();
content.putString(1,contentStr);
tt.commit();
}catch(Exception e){
tt.rollback();
e.printStackTrace();
}finally{
session.close();
sessionFactory.close();
}
}
实体类
…………
private Clob content;
private String contentStr;
public Clob getcontent() {
return content;
}
public void setcontent(Clob content) {
this.content= content;
}
public String getcontentStr() {
return contentStr;
}
public void setcontentStr(String contentStr) {
this.contentStr= contentStr;
}
…………
实体Form
private String contentStr;
public String getcontentStr() {
return contentStr;
}
public void setcontentStr(String contentStr) {
this.contentStr= contentStr;
}
现在的问题是在 save方法中的oracle.sql.CLOB content = (oracle.sql.CLOB)news.getContent();这一步返回的content是null
请问是为什么??