我尝试了下面的代码。我同时使用图像和文本进行更新,但出现应用程序错误。无法推断用于我遇到的此错误实例的 SQL 类型。
QuestionRef questionRef = ceBean.get("questionRef");
QuestionRef oldQuestionRef = this.getQuestionRef(ceBean);
questionRef.setAnswerId(oldQuestionRef.getAnswerId());
int i = 0;
MultipartFile[] answerImage = questionRef.getAnswerImage();
for (String answer : questionRef.getAnswerId()) {
QuestionAns questionAns = new QuestionAns();
if (answerImage[i].getSize() > 0) {
questionAns.setImage_answer(XUtil.encodeToBase64(answerImage[i].getBytes()));
ceBean.put("questionAns", questionAns);
questionRefDAO.updateAnswerImage(ceBean);
}
else if (StringUtils.isNotBlank(questionRef.getAnswer()[i])) {
ceBean.put("questionAns", questionAns);
questionRefDAO.updateAnswer(ceBean);
}
i++;
}
Long q_id = questionRef.getQuestion_id();
questionRef.setQuestion_id(q_id);
ceBean.put("questionRef", questionRef);
questionRefDAO.updateQuestionRef(ceBean);