Mybatis中example类的使用

更新时间:2023-07-20 20:07:28 阅读: 评论:0

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

本文发布于:2023-07-20 20:07:28,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/78/1107551.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

下一篇:example08
标签:查询   字段   条件   增删   实例   类型   改查   单表
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图