-
Notifications
You must be signed in to change notification settings - Fork 657
Closed as not planned
Labels
questionFurther information is requestedFurther information is requested
Description
Describe the bug
In my framework, which uses MyBatis-Flex, data is inserted within the same transaction, and the insertion returns successfully. The data can also be queried within the transaction. However, after the request ends, the data is lost when queried in a subsequent request, even though other data within the same transaction remains intact.
To Reproduce
Provide a sample code that reproduces the error.
TransactionManager.execTransaction(() -> {
try {
List<MESPay> addPayList = processMarkingPayBO.getAddPayList();
log.info("营销SDK-addPayList,size={}", addPayList.size());
if (CollectionUtils.isNotEmpty(addPayList)) {
int count = 0;
for (MESPay mesPay : addPayList) {
count += mesPayDao.create(mesPay);
}
log.info("营销SDK-addPayList,count={}", count);
List<MESPay> mesPays =
`mesPayDao.queryByOrderKeyIgnoreLogicDelete(addPayList.get(0).getEdgeOrderKey());`
log.info("营销SDK-orderKey,mesPays={}", JSONObject.toJSONString(mesPays));
}
if (CollectionUtils.isNotEmpty(updatePayList)) {
updatePayList.forEach(mesPayDao::update);
}
} catch (Exception e) {
log.error("error happened.", e);
throw new BusinessException(ErrorCode.FAILED_ADD_PAY_PAY_EXIST, "保存营销活动失败");
}
return 1;
});
public class TransactionManager {
public static <TT> TT execTransaction(Supplier<TT> supplier) {
boolean needLock = DatabaseHelper.databaseType() == DatabaseType.SQLITE;
if (needLock) {
synchronized (SynchronizedBaseDao.class) {
return Db.txWithResult(supplier);
}
} else {
return Db.txWithResult(supplier);
}
}
}Expected behavior
The data was inserted successfully, and it can also be queried.⬤
Environment (please complete the following information):
- OS: [Windows 7]
- CPU architecture: [x86_64, intel]
- sqlite-jdbc version [3.39.3.0]
Additional context
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested
