开发者

i am using spring+hibernate and i m getting error : org.springframework.dao.InvalidDataAccessResourceUsageException

i am using spring+hibernate and i m getting error when i upload doc file using rich:upload component, doc is upl开发者_开发技巧oaded sucessfully but when i click ok it gives following error. The field is byte[] doc;

org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert: [com.eTender.model.UploadDoc]; nested exception is org.hibernate.exception.DataException: could not insert: [com.eTender.model.UploadDoc]


Problem Solved.

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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜