Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH);
  2. try {
  3. SimpleTableMapper mapper = session.getMapper(SimpleTableMapper.class);
  4. List<SimpleTableRecord> records = getRecordsToInsert(); // not shown
  5.  
  6. BatchInsert<SimpleTableRecord> batchInsert = insert(records)
  7. .into(simpleTable)
  8. .map(id).toProperty("id")
  9. .map(firstName).toProperty("firstName")
  10. .map(lastName).toProperty("lastName")
  11. .map(birthDate).toProperty("birthDate")
  12. .map(employed).toProperty("employed")
  13. .map(occupation).toProperty("occupation")
  14. .build()
  15. .render(RenderingStrategy.MYBATIS3);
  16.  
  17. batchInsert.insertStatements().stream().forEach(mapper::insert);
  18.  
  19. session.commit();
  20. } finally {
  21. session.close();
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement