获取 ibatis 中批量插入/更新的更新计数
使用最新版本的mybatis。有一个映射器和 DAO。进行批量插入。它有效,但我想知道插入了多少行。在 JDBC 中,我可以将更新计数作为 int 数组获取。如何在 mybatis/ibatis 中获取它?
Mapper..
@Insert(NEW_ORDER)
int create(final OrderBatch order); // represents one row to insert
DAO...
public int createOrders(SqlSession session, List<OrderBatch> orders) {
OrderBatchMapper mapper = session.getMapper(OrderBatchMapper.class);
for (OrderBatch order : orders) {
// HOW CAN I GET THE int[] or int of update count?
i = mapper.create(order);
}
return i;
}
谢谢
Using the latest version of mybatis. Have a mapper and DAO. Doing batch inserts. Its working but I want to know how many rows were inserted. In JDBC I can get the update counts as an int array .. How can I get this in mybatis/ibatis ?
Mapper..
@Insert(NEW_ORDER)
int create(final OrderBatch order); // represents one row to insert
DAO...
public int createOrders(SqlSession session, List<OrderBatch> orders) {
OrderBatchMapper mapper = session.getMapper(OrderBatchMapper.class);
for (OrderBatch order : orders) {
// HOW CAN I GET THE int[] or int of update count?
i = mapper.create(order);
}
return i;
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用批处理时,语句在事务结束或调用flushStatements 时执行。
执行这个
应该对你有用。
When using batches, statements are executed when the transaction ends or when flushStatements has been called.
Executing this
Should work for you.