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 isorg.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);
}
精彩评论