-
Notifications
You must be signed in to change notification settings - Fork 5
4.1 simple chain
xphsc edited this page Jul 11, 2018
·
4 revisions
3 链式API 简单查询
// 如果查询总数>1会抛异常
User user = easyJdbcTemplate.selector()
.SELECT("user_name")
.FROM("t_user")
.WHERE("user_name=?")
.entityClass(User.class)
.parameters("张三")
.get();
User user = easyJdbcTemplate.selector()
.SELECT("user_ame")
.FROM("t_user")
.WHERE("user_name=?")
.entityClass(User.class)
.parameters("张三")
.count();
List<User> users = easyJdbcTemplate.selector()
.SELECT("user_name")
.FROM("t_user")
.WHERE("u.user_name=?")
.entityClass(User.class)
.parameters("张三")
.list();
List<UserDTO > dtos = easyJdbcTemplate.selector()
.SELECT("u.id,u.user_name")//select 语句
.FROM("t_user u")//from语句
.WHERE("u.id=?")//where语句
.mapping("id","userId") //数据库t_user表字段id映射DTO对象UserDTO字段userId
.parameters("1").entityClass(UserDTO .class)//要组装的类
.limit(20)//查询条数
.list();//查询
assassination