Mybatis中example类的使⽤
要使⽤example类,先要在项⽬中导⼊mybatis.mapper的jar包。fright
Mapper接⼝中包含了单表的增删改查以及分页功能。
给出实例:
CountryMappermapper = Mapper(Country.class);
//Country.class是实体类
//查询操作
List<Country>cList = mapper.lect(new Country());石家庄留学中介
现在使⽤Example查询
Example example =new Example(Country.class);
水调歌头翻译/
/这⾥给出查询为id=100
cList = mapper.lectByExample(example);
pingguoyuanexample.tOrderByClau(“字段名ASC”); 以某字段升序排序
example.tDistinct(fal)//去除重复,boolean型,true为选择不重复的记录
lectByExample()返回的是⼀个集合
韩语的谐音mybatis中mapper的实例函数:
int countByExample(UrExample example) thorws SQLException:按条件计数。
int deleteByPrimaryKey(Integer id) thorws SQLException:按主键删除。
int deleteByExample(UrExample example) thorws SQLException:按条件删除。
raString/Integer inrt(Ur record) thorws SQLException:插⼊(返回值为id值)
Ur lectByPrimaryKey(Integer id) thorws SQLException:按主键查询。words
disaster是什么意思
List<?>lectByExample(UrExample example) thorws SQLException:按条件查询
12月英文
List<?>lectByExampleWithBLOGs(UrExample example) thorws SQLException:按条件查询(包括BLOB字段)。只有当数据表中的字段类型有为⼆进制的才会产⽣。
int updateByPrimaryKey(Ur record) thorws SQLException:按主键更新
int updateByPrimaryKeySelective(Ur record) thorws SQLException:按主键更新值不为null的字段
int updateByExample(Ur record, UrExample example) thorws SQLException:按条件更新
int updateByExampleSelective(Ur record, UrExample example)thorws SQLException:按条件更新值不为null的字段
mybatis中mapper的实例函数详解:
lectByPrimaryKey()olor
Country country = ##Mapper.lectByPrimaryKey(100);
相当于lect * from ur where id = 100
还有⼀些⽅法不在这⾥赘述,可以参考mybatis中的example