public void insert(final Order order, final Long userId) throws Exception{
Long orderId = Long.valueOf(0);
try {
Trans.exec(new Atom(){
public void run() {
dao().insert(order);
Sql sql = Sqls.create("INSERT INTO $table (orderId,userId) VALUES(@orderid,@userid)");
// 为变量占位符设值
sql.vars().set("table","order_user");
// 为参数占位符设值
sql.params().set("orderid",order.getId()).set("userid",userId);
dao().execute(sql);
orderId = order.getId();
}
});
} catch (Exception e) {
System.out.println(e.toString());
throw new BusinessException(ResponseCodes.RESPONSE_CODE_SYSTEM_ERROR);
}
}
添加回复
请先登陆