Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH);
- try {
- SimpleTableMapper mapper = session.getMapper(SimpleTableMapper.class);
- List<SimpleTableRecord> records = getRecordsToInsert(); // not shown
- BatchInsert<SimpleTableRecord> batchInsert = insert(records)
- .into(simpleTable)
- .map(id).toProperty("id")
- .map(firstName).toProperty("firstName")
- .map(lastName).toProperty("lastName")
- .map(birthDate).toProperty("birthDate")
- .map(employed).toProperty("employed")
- .map(occupation).toProperty("occupation")
- .build()
- .render(RenderingStrategy.MYBATIS3);
- batchInsert.insertStatements().stream().forEach(mapper::insert);
- session.commit();
- } finally {
- session.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement