首页 > 代码库 > ibatis使用经验总结
ibatis使用经验总结
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) {
}
}
本文出自 “小李广之博客” 博客,请务必保留此出处http://6817977.blog.51cto.com/6807977/1569627
ibatis使用经验总结