- public void testInserBatch() {
- Session session = sf.openSession();
- session.beginTransaction();
- //每次插入20条数据
- for(int i=0; i<1000; i++) {
- Category c = new Category();
- c.setName("test" + i);
- session.save(c);
- if (i%20==0) {
- session.flush();
- }
- }
- session.getTransaction().commit();
- session.close();
- }
hibernate批量插入数据
最新推荐文章于 2018-11-06 19:48:17 发布
