- 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批量插入数据
最新推荐文章于 2024-06-09 20:15:00 发布