Mybatis在插入自增字段时,会对当前对象未赋值的自增字段进行赋值
OrderItem orderItem = new OrderItem(); System.out.println("==========");
System.out.println(orderItem);//此时输出OrderItem{id=null, pid=null, oid=null, uid=null, number=null, product=null}
orderItem.setPid(pid);
orderItem.setUid(user.getId());
orderItem.setNumber(num);
System.out.println("==========");
System.out.println(orderItem);//此时输出OrderItem{id=null, pid=91, oid=null, uid=1, number=1, product=null}
orderItemService.add(orderItem);
System.out.println("==========");
System.out.println(orderItem);//此时输出OrderItem{id=6, pid=91, oid=null, uid=1, number=1, product=null}
以上是 Mybatis在插入自增字段时,会对当前对象未赋值的自增字段进行赋值 的全部内容, 来源链接: utcz.com/z/512995.html