iBatis 的修改一个实体

Student.xml

    <update id="updateStudent" parameterClass="Student" >
        UPDATE Student SET age=#age# WHERE (Id=#id#)
    </update>

StudentImpl.java

    public void upStudent(Student student) {
        // TODO Auto-generated method stub
         try {
            sqlMapClient.update("updateStudent",student);
        } 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    
    Student student = new Student();
    student.setId(1);
    student.setAge(50);
    IStudent istudent5 = new StudentImpl();
    istudent5.upStudent(student);
    
    }
    

}

 

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

导航