1) Batch save only connect to database once, performance is efficient;
The corresponding save SQL is the same as the general;
@SuppressWarnings ({"Unchecked", "Rawtypes"})
@Override
public void Saveattachmentownerinfo (final list<attachmentownerdto> attachmentownerlist,
Final string Idattachmentowner, final string applypolicyno) throws Pafadaoexception {
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 ("Personnelinfo.saveattachmentownerinfo", attachownerdto);
count++;
if (count = = 50) {
Sme.executebatch ();
Count = 0;
}
}
Sme.executebatch ();
return null;
}
});
} catch (Exception e) {
Java.out.println (json.tojsonstring (attachmentownerlist));
}
}
This article is from the "Small Li Guangzhi Blog" blog, please be sure to keep this source http://6817977.blog.51cto.com/6807977/1597101
Ibatis Bulk execution of Save operations