public void insertUndoRecordsIntoReport(final List<Object[]> recordsNeeded, final int monitoring_report_id) {
final String sql =" insert into record (case_id, pass, level_id, info, project_id, module_id, monitoring_id, alternative, monitoring_report_id) " +
" values ( ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
this.getHibernateTemplate().execute(
new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException,
SQLException {
java.sql.Connection con = session.connection();
java.sql.PreparedStatement stmt = con.prepareStatement(sql);
for (Object[] recordNeeded:recordsNeeded) {
stmt.setString(1,recordNeeded[1].toString());
stmt.setLong(2, 0);
stmt.setLong(3, 4);
stmt.setString(4, "用例未执行");
stmt.setString(5, recordNeeded[4].toString());
stmt.setString(6, recordNeeded[3].toString());
stmt.setString(7, recordNeeded[2].toString());
stmt.setString(8, recordNeeded[0].toString());
stmt.setLong(9, monitoring_report_id);
stmt.addBatch();//将插入的任务添加到批处理中
}
stmt.executeBatch();//执行批量任务
stmt.close();
session.flush();
session.close();
return null;
}
}
);
}
public void batchSaveCardDetail(List<TCardInfo> cardDetails) {
return this.getHibernateTemplate().execute(new HibernateCallback() {
@Override
public Object doInHibernate(Session session) throws HibernateException, SQLException {
for (int i = 0; i < cardDetails.size(); i++) {
session.save(cardDetails.get(i));
if (i % 50 == 0) {
session.flush();
session.clear();
}
}
return null;
}
});
}