1、先看看俩种调用方式
public static void main(String[] args) {
SqlSessionFactory sqlSessionFactory;
SqlSession session = null;
try {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
session = sqlSessionFactory.openSession();
HashMap<String,String> result = session.selectOne("selectBlog", 110);
System.out.println("Result: "+result);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if(session != null){
session.close();
}
}
}
public static void main(String[] args) {
SqlSessionFactory sqlSessionFactory;
SqlSession session = null;
try {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
session = sqlSessionFactory.openSession();
ReleaseDTOMapper mapper = session.getMapper(ReleaseDTOMapper.class);
HashMap<String,String> param = new HashMap<String,String>();
param.put("STATE", "N");
param.put("UPGRADE_ID","2");
HashMap<String,String> result = mapper.getReleaseNote(param);
System.out.println("Result: "+result);
List<HashMap<String,String>> rs = mapper.getUpgradeNote();
for(HashMap<String,String> r : rs){
System.out.println("Result: "+r);
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if(session != null){
session.close();
}
}
}
2 整体结构
其他知识点
mybatis 一二级缓存
Spring-mybatis 缓存失效问题
ref
https://blog.csdn.net/Vera1114/article/details/78763322
https://www.jianshu.com/p/73ee8caddc68
https://baijiahao.baidu.com/s?id=1595688310049388329&wfr=spider&for=pc
http://www.crazyant.net/2022.html
https://blog.csdn.net/chenyao1994/article/details/79233725