1)下面的代码实现ibatis批量保存的功能
public void saveAttachmentOwnerInfo(final List<AttachmentOwnerDTO> attachmentOwnerList,
final String idAttachmentOwner, final String applyPolicyNo) {
try {
this._execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor sme) throws SQLException {
sme.startBatch();
int count = 0;
for (AttachmentOwnerDTO attachOwnerDTO : attachmentOwnerList) {
attachOwnerDTO.setAttachmentOwnerId(idAttachmentOwner);
attachOwnerDTO.setApplyPolicyNo(applyPolicyNo);
sme.insert("saveAttachmentOwnerInfo", attachOwnerDTO);
count++;
if (count == 50) {
sme.executeBatch();
count = 0;
}
}
sme.executeBatch();
return null;
}
});
} catch (DataAccessException e) {
}
}
时间: 2024-11-08 21:12:13