我使用TokuMx来组织事务。它有特定的命令来这样做。
我试图运行db.runCommand("beginTransaction") in 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;
}发布于 2014-06-25 17:13:43
我不是jongo专家,但我做托卡姆的工作,我只是检查了jongo的文档。我想你想
PlayJongo.jongo().runCommand("{beginTransaction:1}");https://stackoverflow.com/questions/24408924
复制相似问题