/**
* 发布成绩
* @param scoreList
* @param examList
*/
public void publishScore(List<NationScoreinfo> scoreList,
List<NationExamineedetail> examList) {
nationScoreinfoDao.getSession().doWork(new PublishScoreWork(scoreList,examList));
}
private static class PublishScoreWork implements Work{
List<NationScoreinfo> scoList ;
List<NationExamineedetail> exList;
public PublishScoreWork(List<NationScoreinfo> scoreList,List<NationExamineedetail> examList){
scoList = scoreList;
exList = examList;
}
@Override
public void execute(Connection connection) throws SQLException {
PreparedStatement pstmt=connection.prepareStatement("update nation_scoreinfo ns set ns.score_status = '"+EScoreStatus.releaseSuccess.toString()+"' where ns.uuid = ?");
pstmt.clearBatch();
for(NationScoreinfo r : scoList){
pstmt.setString(1, r.getUuid());
pstmt.addBatch();
}
pstmt.executeBatch();
pstmt=connection.prepareStatement("update nation_examineedetail ne set ne.status = '"+EExamStatus.scoreQuery.toString()+"' where ne.uuid = ?");
for(NationExamineedetail ne : exList){
pstmt.setString(1, ne.getUuid());
pstmt.addBatch();
}
pstmt.executeBatch();
System.out.println("批量发布完成");
}
}
必须注意 pstmt.addBatch(); 使用
标签:examList,hibernate,批量,List,ne,提高效率,scoreList,exList,pstmt From: https://blog.51cto.com/u_16071779/6194498