hibernate批量写入
public int insertChanDaoTaskModel(List<T> t) {
// TODO Auto-generated method stub
Session session = this.hibernateTemplate.getSessionFactory().openSession();
Transaction tran = session.beginTransaction();
tran.begin();
try {
for(int i=0;i<t.size();i++){
session.save(t.get(i));
if(i%2000==0){
session.flush();
session.clear();
}
}
tran.commit();
session.close();
return 1;
}
catch (Exception ex) {
// TODO: handle exception
return 0;
}
}