ibatis学习笔记(二) 基本操作
来源:互联网 发布:painter软件破解版 编辑:程序博客网 时间:2024/05/29 14:55
ibatis学习笔记(二)基本操作
上一次,做了一个简单的ibatis的例子,这回想针对上次的例子在继续研究
1.基本操作实例
(1)数据写入操作
Product prod = new Product(); prod.setName("联想 T400 笔记本");prod.setPrice(8999);sqlMap.startTransaction();sqlMap.insert("insertProduct", prod);sqlMap.commitTransaction();
(2)数据查询
Product prod = (Product)sqlMap.queryForObject("getProduct", 1);
(3)在指定对象中存放查询结果
Product prod = new Product();sqlMap.queryForObject("getProduct", 1, prod);
(4)执行批量查询
sqlMap.queryForList("getAllUser", null);
(5)关于Auto Commit
自动执行
(6)查询指定范围内的数据
sqlMap.queryForList("getAllUser", null,1,1);
(7)结合RowHandler进行查询(select)
public class MyRowHandler implements RowHandler {public void handleRow (Object object, List list) throwsSQLException {Product product = (Product) object;product.setQuantity (10000);sqlMap.update (“updateProduct”, product);}}sqlMap.startTransaction();RowHandler rowHandler = new MyRowHandler();List list = sqlMap.queryForList (“getProductList”, null,rowHandler);sqlMap.commitTransaction();
(8) 分页查询
PaginatedList list =sqlMap.queryForPaginatedList (“getProductList”, null, 10);list.nextPage();list.previousPage();
(9)基于Map的批量查询(select)
sqlMap.startTransaction();Map map = sqlMap.queryForMap (“getProductList”, null,“productCode”);sqlMap.commitTransaction();Product p = (Product) map.get(“EST-93”);
- ibatis学习笔记(二) 基本操作
- ibatIS学习笔记---Ibatis的基本使用方法
- Webdriver学习笔记(二)浏览器的基本操作
- OpenCV 学习笔记 ----图像的基本操作(二)
- OpenCV_Python 学习笔记(二)图像的基本操作
- NiFi学习笔记(二)——基本操作介绍
- openCV学习笔记(二)---openCV系列基本操作
- openCV学习笔记(二)---openCV系列基本操作(2)
- iBATIS系统学习笔记二
- ibatis学习(二)--ibatis使用介绍
- ibatis学习(二)--ibatis使用介绍
- ibatis学习(二)--ibatis使用介绍
- ibatis学习(二)--ibatis使用介绍
- ibatis学习(二)--ibatis使用介绍
- MySQL学习笔记之二:数据库和表基本操作
- Redis学习笔记二 CentOS下的基本操作
- 学习EMACS基本操作(二)
- MySQL学习历程(二):基本操作
- Vmware Server不能启动的解决方法(8333\32)
- C++字符串完全指引
- 使用位与运算代替取模运算
- eclipse常用插件在线安装地址或下载地址
- Java基础学习之(二)—对象与类的方法参数
- ibatis学习笔记(二) 基本操作
- 【微软面试题1】任意改变CPU占有率的几种方法【限winxp系统】
- jQuery事件
- 理解 JVM 如何使用本机内存
- android利用matrix对图片中心旋转
- 分布式搜索方案选型之三:SolrCloud
- 浅谈Java中数据在内存中的状态,以及String、StringBuffer、==、equals、数组等问题
- 一线网页游戏程序员日志 (十五)
- GROUP BY 语句