iBatis 的删除一条记录

 

Student.xml 设置删除参数的类型,可以是一个对象的

    <delete id="delStudent" parameterClass="int" >
    DELETE FROM Student WHERE (Id=#id#)
    </delete>

StudentImpl.java   调用删除方法

    public void delStudent(int id) {
        // TODO Auto-generated method stub
        try {
            sqlMapClient.delete("delStudent",id);
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

 

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 istudent4 = new StudentImpl();
    istudent4.delStudent(2);
    
    }
    

}

 

posted on 2015-01-07 17:31  手撕高达的村长  阅读(642)  评论(0编辑  收藏  举报

导航