我遇到的情景描述如下:
1、在自己的Service类中定义了一个方法m1(),并且用@Before(Tx.class)进行了注解,如下:
public Class ContractAccountService {
public String customerId;
public ContractAccountService() {}
public ContractAccountService(String customerId) {
    this.customerId = customerId;
}
@Before(Tx.class)
public void m1() {
    String ids = "";
    for (int i = 0; i < 10; i++) {
          CustomerAccount acc = new CustomerAccount();
          acc.set("id", i);
          acc.save();
          ids += "," + i
    }
    Db.update(" update customer_account t set t.account_type='personal' where t.id in (?) ", ids);
}
}2、在controller中调用m1(),如下:
public Class MyController {
    public void test() {
        ContractAccountService service = Enhancer
            .enhance(new ContractAccountService("JSIWOOSOW*K@"));
        service.m1();
    }
}3、m1方法中先调用了Model.save()保存了若干数据,然后调用了Db.update()方法用来更新前面保存的若干数据,但是发现Db.update()方法并没有生效。确切的说,是Db.update()执行的返回值是0 。
 项目:JFinal
 
在这里可以继续编辑该文章:
http://www.jfinal.com/my/feedback
注意点击右侧的编辑链接