NutzCN Logo
问答 @Prev 注解无效
发布于 2887天前 作者 qq_b6ef7101 3233 次浏览 复制 上一个帖子 下一个帖子
标签: dao insert
@Table("product_order")
public class ProductOrderBean {

    @Id(auto=false)
    private int id;

    @Column("pro_id")
    private int proID;

    @Column("types") 
    private int types;

    @Prev(@SQL(value = "SELECT count(1) + 1 as cnt FROM product_order WHERE types=@types"))
    @Column
    private int orders;

    @Column
    private int del;
}
5 回复

试了一下,并没有问题

17:46:56.136 DEBUG (NutDaoExecutor.java:388) printSQL - SELECT count(1) + 1 as cnt FROM product_order WHERE types=?
    | 1 |
    |---|
    | 0 |
  For example:> "SELECT count(1) + 1 as cnt FROM product_order WHERE types=0"
17:46:56.137 DEBUG (DaoTimeInterceptor.java:28) filter - time=1ms, sql=SELECT count(1) + 1 as cnt FROM product_order WHERE types=0
17:46:56.139 DEBUG (NutDaoExecutor.java:388) printSQL - INSERT INTO product_order(id,pro_id,types,orders,del) VALUES(?,?,?,?,?) 
    |         1 | 2 | 3 | 4 | 5 |
    |-----------|---|---|---|---|
    | 981899008 | 0 | 0 | 2 | 0 |
  For example:> "INSERT INTO product_order(id,pro_id,types,orders,del) VALUES(981899008,0,0,2,0) "
17:46:56.141 DEBUG (DaoTimeInterceptor.java:28) filter - time=2ms, sql=INSERT INTO product_order(id,pro_id,types,orders,del) VALUES(981899008,0,0,2,0) 

奇怪 ,为啥我这就不执行
Trans.exec(new Atom(){
public void run() {
String[] t = typeStr.split(",");
for(int i = 0,len = t.length;i<len;i++){
ProductOrderBean pob = new ProductOrderBean();
pob.setDel(0);
pob.setProID(proid);
pob.setTypes(Integer.parseInt(t[i]));
dao.fastInsert(pob);
}
}
});

原来使用也没碰见 这种问题

fastInsert是不执行@Prev的

不能用fastInsert 插入 , 用Insert 就可以了

添加回复
请先登陆
回到顶部