public void batchProcessCards(final List<Card> listOfCard) {
getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
for(int i = 0; i < listOfCard.size(); i++) {
session.saveOrUpdate(listOfCard.get(i));
if(i % 100 == 0) {
session.flush();
session.clear();
}
}
return null;
}
});
}
Hibernate-批量新增
最新推荐文章于 2022-02-21 22:02:36 发布