The Insert method uses all properties as fields
@Test public
void Testinsert () {
user record=new User ();
Record.setname ("SanSan");
Use This.newUserMapper.insert (record) with all attributes as fields
;
}
Results:
2017-08-03 15:06:03,946 [main] [Cn.itcast.mybatis.mapper.newusermapper.insert]-[debug] ==> Preparing: Insert Into Tb_user (age,user_name,id,name,birthday,sex,password,updated,created) VALUES (?,?,?,?,?,?,?,?,?)
2017-08-03 15:06:03,973 [main] [Cn.itcast.mybatis.mapper.newusermapper.insert]-[debug] ==> parameters:null, NULL, NULL, SanSan (String), NULL, NULL, NULL, NULL, NULL
2017-08-03 15:06:04,010 [main] [Cn.itcast.mybatis.mapper.newusermapper.insert]-[debug] <== updates:1
2017-08-03 15:06:04,014 [main] [Cn.itcast.mybatis.mapper.newusermapper.insert!selectkey]-[debug] ==> Executing: SELECT last_insert_id ()
2017-08-03 15:06:04,025 [main] [Cn.itcast.mybatis.mapper.newusermapper.insert!selectkey]-[debug] <== total:1
insertselective Insert data, use a non-null property as a field
@Test public
void Testinsertselective () {
user record=new User ();
Record.setname ("test_insertselective"); Insert data, use This.newUserMapper.insertSelective (record) as a field with a non-null property
;
}
Results:
2017-08-03 14:41:30,406 [main] [Cn.itcast.mybatis.mapper.newusermapper.insertselective]-[debug] ==> Preparing: INSERT into Tb_user (id,name) VALUES (?,?)
2017-08-03 14:41:30,434 [main] [Cn.itcast.mybatis.mapper.newusermapper.insertselective]-[debug] ==> Parameters: NULL, test_insertselective (String)
2017-08-03 14:41:30,477 [main] [Cn.itcast.mybatis.mapper.newusermapper.insertselective]-[debug] <== updates:1
2017-08-03 14:41:30,481 [main] [Cn.itcast.mybatis.mapper.newusermapper.insertselective!selectkey]-[debug] ==> Executing:select last_insert_id ()
2017-08-03 14:41:30,493 [main] [Cn.itcast.mybatis.mapper.newusermapper.insertselective!selectkey]-[debug] <== Total:1