逆向工程的Example类用法
来源:互联网 发布:骆驼 薛之谦 知乎 编辑:程序博客网 时间:2024/06/13 22:30
package com.imooc.entity;public class Student { /** */ private Integer id; /** */ private String name; /** */ private Integer age; /** */ private Integer score; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name == null ? null : name.trim(); } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public Integer getScore() { return score; } public void setScore(Integer score) { this.score = score; }}
And
Or
package com.imooc.test;import java.util.List;import org.apache.ibatis.session.SqlSession;import com.imooc.dao.StudentMapper;import com.imooc.entity.Student;import com.imooc.entity.StudentExample;import com.imooc.entity.StudentExample.Criteria;import com.imooc.untils.MyBatisUntil;public class Main {public static void main(String[] args) {//获得SqlSession对象SqlSession sqlSession=MyBatisUntil.getSqlSession();//获得StudentMapperStudentMapper dao=(StudentMapper)sqlSession.getMapper(StudentMapper.class);StudentExample example=new StudentExample();Criteria c1=example.createCriteria();//select * from student where age between 11 and 22c1.andAgeBetween(11, 22);Criteria c2=example.createCriteria();//select * from student where age < 11c2.andAgeLessThan(11);//(select * from student where age between 11 and 22) or ( select * from student where age < 11 )//如果不写这一句select * from student where age between 11 and 22example.or(c2);// 等价于 C1 or C2//example.or(c3);// 等价于 C1 or C2 or C3List<Student> students=dao.selectByExample(example);for (Student student : students) {System.out.println(student);}}}
阅读全文
1 0
- 逆向工程的Example类用法
- ###逆向工程的Example类用法==注意:【没写example.createCriteria();执行selectByExample(example)表示:查询全部】
- mybatis逆向工程生成的Example类的使用
- mybatis逆向工程的Example类用法==笔记==【单表操作只需调用,多表查询需要自定义sql+mapper接口方法(待补全)】
- mybatis逆向工程问题:多次访问同一example类总是缓存第一次的结果。
- 【翻译】Delphi中类的逆向工程
- MFC的逆向工程
- 逆向工程的应用
- mybatis 的逆向工程
- mybatis的逆向工程
- mybatis的逆向工程
- mybatis的逆向工程
- Mybatis的逆向工程
- powerdesigner的逆向工程
- MyBatis 的逆向工程
- mybatis的逆向工程
- mybatis的逆向工程
- Mybatisd的逆向工程
- 20. Valid Parentheses
- bzoj 4999 This problem is too simple 树链剖分+动态开点线段树
- POJ
- MVC模式实现(上)
- Python08_IO编程
- 逆向工程的Example类用法
- HDU 2222 Keywords Search (AC自动机模板题)
- 文章标题
- bwboundaries函数使用--标记不同的区域
- 第三周周中总结
- oracle数据库基础
- Fiddler抓包手机APP数据,wireshark,charles
- Python09_进程与线程
- 应用层-4、Email应用