iBatis 的条件查询
之类以传入ID进行举例
Student.xml 在里面设置一个ID的标志位,设置类型
<select id="selectAllStudentByid" parameterClass="int" resultClass="Student">
select * from
student
where Id=#id#
</select>
StudentImpl.java文件,这里将ID给传入进去,
public List<Student> selStudentByid(int id) {
List<Student> student = null;
try {
student = sqlMapClient.queryForList("selectAllStudentByid",id);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return student;
}
Test.java测试页面
package cn.test.main; import java.util.List; import cn.test.domain.Student;
import cn.test.service.IStudent;
import cn.test.service.StudentImpl; public class Test { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
IStudent istudent2 = new StudentImpl();
List<Student> student2 = istudent2.selStudentByid(1);
System.out.printf("id="+student2.get(0).getId() + "name = " +student2.get(0).getName() + "age = " + student2.get(0).getAge()); } }
iBatis 的条件查询的更多相关文章
- IBatis按条件分页查询
XML中代码 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sqlMap PUBLIC & ...
- 03_MyBatis基本查询,mapper文件的定义,测试代码的编写,resultMap配置返回值,sql片段配置,select标签标签中的内容介绍,配置使用二级缓存,使用别名的数据类型,条件查询ma
1 PersonTestMapper.xml中的内容如下: <?xmlversion="1.0"encoding="UTF-8"?> < ...
- Ibatis动态(dynamic)查询
Ibatis的动态查询使得数据操作变得非常的灵活,下次举出了常用的动态查询的属性信息: Ibatis配置信息 <!-- Dynamic Sql --> <typeAlias a ...
- oracle 在xml中批量插入,批量修改及多组条件查询
最近公司用ibatis开发项目,本来可以用存储过程处理批量插入,批量修改及多组条件查询:但由于使用模块相对较小,暂时就在xml中配置,以前没有在xml做过类似处理,有必要记录一下:好了,代码如下: & ...
- mybatis学习(五)(动态mybatis(多条件查询))
有时候要查询条件是多条件的,尤其是使用mybatis的时候如何创建sql语句呢? 这里mybatis有自己的办法,如下: 案例:通过传入map,根据map里面的数据来查询 mapper配置如下: &l ...
- Mybatis-技术专区-中的条件查询createCriteria example里面的条件
之前用Mybatis框架反向的实体,还有实体里面的Example,之前只是知道Example里面放的是条件查询的方法,可以一直不知道怎么用,到今天才开始知道怎么简单的用. 在我们前台查询的时候会有许多 ...
- mybatis+maven+父子多模块进行crud以及动态条件查询
使用IDEA创建maven项目,File→New→Project→maven→Next→填写GroupId(例:com.zyl)和ArtifactId(mybatis-demo-parent)→Nex ...
- Mybatis-技术专区-Criteria的and和or进行联合条件查询
之前用Mybatis框架反向的实体,还有实体里面的Example,之前只是知道Example里面放的是条件查询的方法,可以一直不知道怎么用,到今天才开始知道怎么简单的用.在我们前台查询的时候会有许多的 ...
- jqGrid jqGrid分页参数+条件查询
HTML <div class="row"> <div class="col-sm-20"> <form id="for ...
随机推荐
- Jamie's Contact Groups
poj2289:http://poj.org/problem?id=2289 题意:给定一个规模为n的名单,要将名单中的人归到m个组中,给出每个人可能的分组号,需要确定一种分配方案,是的最大规模的组最 ...
- codeforces D. Pashmak and Parmida's problem
http://codeforces.com/contest/459/problem/D 题意:给你n个数,然后统计多少组(i,j)使得f(1,i,ai)>f(j,n,aj); 思路:先从左往右统 ...
- MEMS Gyroscope Technology
InvenSense®Technology Overview Our technology is comprised of five coreelements: our patented Nasiri ...
- poj1637
混合图欧拉回路首先先明确基本概念连通的无向图存在欧拉回路当且仅当不存在奇点连通的有向图当且仅当每个点入度=出度这道题我们显然应该当作连通的有向图来做这个问题的困难之处在于我不知道应该从无向边的什么方向 ...
- 挖坑#3-----DP优化+CDQ分治+期望DP
1492: [NOI2007]货币兑换Cash 1176: [Balkan2007]Mokia 1452: [JSOI2009]Count 1563: [NOI2009]诗人小G tyvj1309 ...
- 移动存储卡仍然用FAT32文件系统的真相
微软在2001年就为自家的XP系统的本地磁盘默认使用了NTFS文件系统,但是12年之后,市面上的USB可移动设备和SD卡等外置存储器仍然在用着FAT32文件格式,这是什么理由让硬件厂商选择过时的文件系 ...
- (转载)javascript客户端生成MD5值的函数代码
(转载)http://www.jb51.net/article/26223.htm 用js实现的客户端即可实现md5值的代码,一般情况下都是后台语言才有的,客户端也有了,方便有需要的朋友了. 测试代码 ...
- 未能导入activex控件,请确保它正确注册"的完美解决方案
这个错误“未能导入activex控件,请确保它正确注册”昨天下午让我和我同事花费了3个小时来调试这个错误,在使用VS2010的winfrom编程时加入com组件的时候,报这个错误(以一个客户的机器上) ...
- HDU --3549
Flow Problem Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Tota ...
- HDOJ 1013题Digital Roots 大数,9余数定理
Problem Description The digital root of a positive integer is found by summing the digits of the int ...