paascloud/paascloud-master · error · OmcBizException

OMC10031009

OMC10031009

Error message

OMC10031009

What it means

OMC10031009 means '批量插入订单明细失败' (batch insert of order details failed). batchInsertOrderDetail checks the number of rows the MyBatis mapper reports as inserted and throws if insertResult < omcOrderDetailList.size(), i.e. the batch write did not persist every order-detail row.

Solutions

  1. Inspect DB logs / enable SQL logging to find which rows failed and why (constraints, packet size).
  2. Check that every OmcOrderDetail has required non-null fields (orderId, productId, userId, quantity, price) before the call.
  3. Split very large batches into chunks (e.g. 500–1000 rows) to avoid packet/statement-size limits.
  4. Ensure the method runs inside a transaction so a partial insert is rolled back, then retry the whole batch.

Example fix

// before
omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);
// after (chunked, defensive)
if (CollectionUtils.isNotEmpty(omcOrderDetailList)) {
    List<List<OmcOrderDetail>> chunks = Lists.partition(omcOrderDetailList, 500);
    for (List<OmcOrderDetail> chunk : chunks) {
        omcOrderDetailService.batchInsertOrderDetail(chunk);
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Java, sanity-check inputs before batch insert
if (CollectionUtils.isEmpty(omcOrderDetailList)) {
    return; // nothing to insert, avoid misleading failure
}
for (OmcOrderDetail d : omcOrderDetailList) {
    if (d.getOrderId() == null || d.getProductId() == null || d.getUserId() == null) {
        throw new IllegalArgumentException("Order detail missing required fields");
    }
}

Try / catch

try {
    omcOrderDetailService.batchInsertOrderDetail(omcOrderDetailList);
} catch (OmcBizException e) {
    if (e.getCode() == ErrorCodeEnum.OMC10031009.getCode()) {
        logger.error("Batch order-detail insert incomplete, size={}", omcOrderDetailList.size(), e);
        throw new OmcBizException(ErrorCodeEnum.OMC10031009); // let @Transactional roll back
    }
    throw e;
}

Prevention

When it happens

Trigger: omcOrderDetailMapper.batchInsertOrderDetail returns a row count smaller than the list size — partial batch failure, list containing rows violating DB constraints, or an empty/oversized batch hitting driver limits.

Common situations: DB constraint violations (null required columns, key collisions) on some rows; oversized batch exceeding max_allowed_packet or JDBC rewrite batch limits; connection issues mid-batch; calling the method with a list where the mapper silently skips entries.

Related errors


AI-assisted analysis of paascloud/paascloud-master@781281a950 (2026-09-10). Data as JSON: /api/errors/94a5c4f0d1344648. Report an issue: GitHub.

Appendix: source

Thrown at paascloud-provider/paascloud-provider-omc/src/main/java/com/paascloud/provider/service/impl/OmcOrderDetailServiceImpl.java:55

	@Override
	public List<OmcOrderDetail> getListByOrderNoUserId(String orderNo, Long userId) {
		Preconditions.checkArgument(userId != null, ErrorCodeEnum.UAC10011001.msg());
		Preconditions.checkArgument(StringUtils.isNotEmpty(orderNo), "订单号不能为空");

		return omcOrderDetailMapper.getListByOrderNoUserId(orderNo, userId);
	}

	@Override
	public List<OmcOrderDetail> getListByOrderNo(String orderNo) {
		Preconditions.checkArgument(StringUtils.isNotEmpty(orderNo), "订单号不能为空");
		return omcOrderDetailMapper.getListByOrderNo(orderNo);
	}

	@Override
	public void batchInsertOrderDetail(List<OmcOrderDetail> omcOrderDetailList) {
		int insertResult = omcOrderDetailMapper.batchInsertOrderDetail(omcOrderDetailList);
		if (insertResult < omcOrderDetailList.size()) {
			throw new OmcBizException(ErrorCodeEnum.OMC10031009);
		}
	}
}

View on GitHub (pinned to 781281a950)