apache / apache/incubator-seata-samples
seata 采用批量保存报io.seata.common.exception.NotSupportYetException异常
- Dominant language
- Java
- Stars
- 2.4k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
seata-server:0.7.1
mybatis-plus
====
@GlobalTransactional
@Transactional
@Override
public SubmitOrderResponseVO submitOrder(OrderSubmitVO orderSubmitVO) {
。。。
//3.保存订单
**saveOrder(order);**
。。。
}
====
public void saveOrder(OrderCreateTO order) {
OrderEntity orderEntity = order.getOrder();
orderEntity.setModifyTime(new Date());
//保存订单
**this.save(orderEntity);** **//执行能成功,与下边的orderItemService.save(orderItem) 都能执行成功,但是下边还有个批量方法就报错。。。**
List orderItems = order.getOrderItems();
if (!CollectionUtils.isEmpty(orderItems)) {
orderItems = orderItems.stream().map(orderItemEntity -> {
orderItemEntity.setOrderId(orderEntity.getId());
return orderItemEntity;
}).collect(Collectors.toList());
**//保存订单项,用批量保存失败,报seata方面的异常。。。
orderItemService.saveBatch(orderItems);**
// for (OrderItemEntity orderItem : orderItems) {
// orderItemService.save(orderItem);//把批量保存换成单个保存,不会报错
// }
}
}
=======
### Error updating database. Cause: io.seata.common.exception.NotSupportYetException
### The error may exist in com/mark/mzoemall/order/dao/OrderItemDao.java (best guess)
### The error may involve com.mark.mzoemall.order.dao.OrderItemDao.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO oms_order_item ( order_id, order_sn, spu_id, spu_name, spu_brand, category_id, sku_id, sku_name, sku_pic, sku_price, sku_quantity, sku_attrs_vals, promotion_amount, coupon_amount, integration_amount, real_amount, gift_integration, gift_growth ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )
### Cause: io.seata.common.exception.NotSupportYetException] with root cause
io.seata.common.exception.NotSupportYetException: null
at io.seata.rm.datasource.AbstractPreparedStatementProxy.addBatch(AbstractPreparedStatementProxy.java:252) ~[seata-all-0.7.1.jar:0.7.1]
======
看了下源码是AbstractPreparedStatementProxy这个方法
public void addBatch() throws SQLException {
**if (RootContext.inGlobalTransaction()) {
throw new NotSupportYetException();**
} else {
((PreparedStatement)this.targetStatement).addBatch();
}
}
Contributor guide
Research direction
Reproduce the failure through orderItemService.saveBatch and inspect OrderItemDao.java alongside AbstractPreparedStatementProxy.java, especially addBatch(). Compare the successful single-save path with the batch path under RootContext.inGlobalTransaction(); done means the reported batch operation no longer raises NotSupportYetException, or the limitation is clearly documented if it remains unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100