zoukankan      html  css  js  c++  java
  • 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());
    
        }
        
    
    }
  • 相关阅读:
    品质家居 生活之魅
    珍爱之礼 美妙感受
    节日礼物清单
    2014新年礼物推荐清单
    Python元组
    python更新列表
    Python列表
    Python 数字
    Python字符串
    python标准数据类型
  • 原文地址:https://www.cnblogs.com/sunxun/p/4208856.html
Copyright © 2011-2022 走看看