Mybatis的insert方法

insert方法

插入所有字段

Account account = new Account();
account.setExpiredDate(org.apache.commons.lang3.time.DateUtils.addDays((new Date()), 90));
account.setAccountStatus(RecordStatusEnum.VALID.getValue());
account.setAccountType(AccountTypeEnum.BIZ_ACCOUNT.getValue());
accountService.insert(account);

insertSelective方法

选择性的插入字段
设置了几个字段,就插入几个字段

Account account = new Account();
account.setExpiredDate(org.apache.commons.lang3.time.DateUtils.addDays((new Date()), 90));
account.setAccountStatus(RecordStatusEnum.VALID.getValue());
account.setAccountType(AccountTypeEnum.BIZ_ACCOUNT.getValue());
accountService.insertSelective(account);

你可能感兴趣的:(————Mybatis)