我正在使用TokuMx
以组织交易。它具有执行此操作的特定命令。
我试着跑db.runCommand("beginTransaction")
进去Mongo shell
。它运作良好。
然而,当我在做同样的事情时Jongo
:
PlayJongo.jongo().runCommand("beginTransaction");
它给了我[error] play - Cannot invoke the action, eventually got an error: java.lang.IllegalArgumentException: Cannot parse query: beginTransaction
我做错了什么?
编辑
public static boolean buyProduct(User buyer, User seller, int accountIndex, float productPrice){
boolean isSuccess = false;
PlayJongo.jongo().runCommand("{beginTransaction : 1}");
try{
// Deposit money to seller
seller.getAccounts().get(0).deposit(productPrice);
UserRepository.update(seller);
// Withdraw money from buyer
buyer.getAccounts().get(accountIndex).withdraw(productPrice);
UserRepository.update(buyer);
throw new Exception();
//isSuccess = true;
}
catch (Exception e){
PlayJongo.jongo().runCommand("{rollbackTransaction : 1 }");
isSuccess = false;
}
return isSuccess;
}