【问题标题】:i am using spring+hibernate and i m getting error : org.springframework.dao.InvalidDataAccessResourceUsageException我正在使用 spring+hibernate 并且我收到错误:org.springframework.dao.InvalidDataAccessResourceUsageException
【发布时间】:2010-08-11 04:43:16
【问题描述】:
我正在使用 spring+hibernate,当我使用 rich:upload 组件上传 doc 文件时出现错误,doc 已成功上传,但是当我单击确定时,它会出现以下错误。字段为byte[]doc;
org.springframework.dao.InvalidDataAccessResourceUsageException:
无法插入:
[com.eTender.model.UploadDoc];
嵌套异常是
org.hibernate.exception.DataException:
无法插入:
[com.eTender.model.UploadDoc]
【问题讨论】:
标签:
hibernate
spring
richfaces
【解决方案1】:
问题解决了。
public void fileUploadListner(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
File imageFilePath = item.getFile();
uploadDocDataBean.setDocname(item.getFileName());
uploadDocDataBean.setDocsize(String.valueOf(item.getFileSize()));
InputStream fileInputStream = new FileInputStream(imageFilePath);
byte[] data = new byte[(int)imageFilePath.length()];
fileInputStream.read(data, 0, (int)imageFilePath.length());
fileInputStream.close();
uploadDocDataBean.setDoc(data);
}