Trans.exec(new Atom(){
public void run() {
//****pay_order 关联指定的用户id
Sql sql1 = Sqls.create("UPDATE pay_order SET user_id = @userId where id = @payOrderId");
sql1.params().set("userId",userId).set("payOrderId",payOrderId);
dao().execute(sql1);
//插入我的订单记录
Sql sql2 = Sqls.create("INSERT INTO my_order(id,user_id,po_id,myordermoney) VALUES(@id,@userId,@payOrderId,@myordermoney)");
sql2.params().set("id",id).set("userId", userId).set("payOrderId",payOrderId).set("myordermoney",myordermoney);
dao().execute(sql2);
}
});
这个事物,发觉第一个数据表修改成功,第二个失败.但是没回滚.