<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Mao 2.0//EN"
"">
<sqlMap>
<typeAlias alias="Student" type="com.jj.ibatis.Student"/>
<select id="selectAllStudent" resultClass="Student">
select *
from student
</select>
<select id="selectStudentById" resultClass="Student"
parameterClass="int">
select *
from student
where id=#id#
</select>
<!-- values中的参数对应POJO类中的get方法,所以不能随便起名,必须和get方法同名 -->
<insert id="insertStudent" parameterClass="Student">
insert into
student(id, name, grade_id, photo, sex)
values (#id#,#name#,#grade_id#,#photo#,#sex#)
</insert>
<delete id="deleteStudentById" parameterClass="int">
delete
from Student
where id=#id#
</delete>
<!-- parameterClass不分大小写 -->
<update id="updateStudent" parameterClass="student">
update student
set name=#name#,
grade_id=#grade_id#,
photo=#photo#,
sex=#sex#
where id=#id#
</update>
<select id="selectStudentByName" parameterClass="String"
resultClass="Student">
select id, name, grade_id, photo, sex
from student
where name like '%$name$%'
</select>
<insert id="insertStudentBySequence" parameterClass="Student">
<selectKey resultClass="int" keyProperty="id">
select studentPKSequence.nextVal
from dual
</selectKey>
insert into
Student(id, name, grade_id, photo, sex)
values (#id#,#name#,#grade_id#,#photo#,#sex#)
</insert>
</sqlMap>
|