.......................
Answer answer=new Answer(); //for循环外new
for(int i=0;i <answerids.length;i++){
answer=(Answer) session.load(Answer.class,new Long(answerids[i]));
answer.setStatus( "答案 ");
session.update(answer);
}
tra.commit();
.......................
//以上代码可以正常更新相应的Answer数据.
.......................
for(int i=0;i <answerids.length;i++){
Answer answer=new Answer(); //for循环内new
answer=(Answer) session.load(Answer.class,new Long(answerids[i]));
answer.setStatus( "答案 ");
session.update(answer);
}
tra.commit();
.......................
//该处只更新最后一条数据
Answer answer=new Answer();