package com.powernode;
import static org.junit.Assert.assertTrue;
import com.powernode.mybatis.mapper.StudentMapper;
import com.powernode.mybatis.pojo.Student;
import com.powernode.mybatis.utils.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AppTest
{
@Test
public void testSimple() throws ParseException {
SqlSession sqlSession = SqlSessionUtil.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
// List<Student> students = mapper.selectById(1L);
// List<Student> students = mapper.selectByName("张三");
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// Date birth = sdf.parse("1990-02-01");
// List<Student> students = mapper.selectByBirth(birth);
Character character = Character.valueOf('男');
List<Student> students = mapper.selectBySex(character);
students.forEach(e -> System.out.println(e.toString()));
sqlSession.close();
}
@Test
public void testMap(){
SqlSession sqlSession = SqlSessionUtil.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
Map<String,Object> map = new HashMap<>();
map.put("name","小明");
map.put("age",23);
map.put("birth",new Date());
map.put("height",1.7);
map.put("sex","女");
int i = mapper.insertStudentMap(map);
System.out.println(i);
sqlSession.commit();
sqlSession.close();
}
@Test
public void testPojo(){
SqlSession sqlSession = SqlSessionUtil.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
Student student = new Student();
student.setName("小猪");
student.setAge(16);
student.setHeight(1.9);
student.setSex('女');
student.setBirth(new Date());
int i = mapper.insertStudentPojo(student);
System.out.println(i);
sqlSession.commit();
sqlSession.close();
}
@Test
public void testParams(){
SqlSession sqlSession = SqlSessionUtil.openSqlSession();
StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);
List<Student> students = mapper.selectByNameAndSex2("小美", '女');
students.forEach(e-> System.out.println(e.toString()));
sqlSession.close();
}
}

飞翔的佩奇

- 粉丝: 7804
最新资源
- 本库是个基于python的工具集,用于记录数据到文件。 使用方便,代码简洁, 是一个可靠、省心且实用的工具。 支持多线程同时写入。.zip
- 本科毕业设计,基于python的图像复制粘贴篡改识别软件。.zip
- 本项目是基于计算机视觉的端到端交通路口智能监控系统.采用的设计架构由SRS
- 碧蓝航线ios平台自动脚本,基于python+opencv+facebook_wda实现.zip
- 毕业设计中基于给定微博数据的反作弊识别,用python开发。.zip
- 毕业设计项目,基于深度学习的实时语义分割算法研究,python实现。.zip
- 对基于python的微博爬虫进行重写,重写语言:java.zip
- 此框架是基于Python+Pytest+Requests+Allure+Yaml+Json实现全链路接口自动化测试
- 程序语言课程作业在线评测平台(实现Java、C、Python的选择、填空、代码题在线评测),基于SpringBoot+Layui+MySQL实现.zip
- 非官方的科大讯飞语音合成(用于朗读,配音场景)python API (基于官方demo增加了:超过2000字上限自动分割再合并音频的功能).zip
- 非官方的简易中国铁路列车运行图系统,基于Python + PyQt5
- 超市POS销售与后台管理系统_商品录入收银业务会员管理进货销售库存人员权限断网收银断电保护_实现超市前台POS销售商品扫描条形码输入收银计算找零打印清单会员折扣累计消费以及后台管理.zip
- 俄罗斯方块闯关版,基于Python实现.zip
- 该项目是基于Python和数据库实现的学生信息管理系统.zip
- 该仓库为agv系统调度软件的前后端实现。项目基于fastapi(python后端框架)和vue2实现了RESTful风格的前后端分离.zip
- 该项目是基于Scrapy框架的Python新闻爬虫,能够爬取网易,搜狐,凤凰和澎湃网站上的新闻,将标题,内容,评论,时间等内容整理并保存到本地.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


