标签:res bsp tab start _id book query engine pac
Book.java
id
name
price
book 表
book_id
book_name
book_price
create table book(
book_id int unsigned auto_increment,
book_name varchar(20),
book_price decimal(8,2),
primary key(book_id)
)engine=innodb charset=utf8;
BookMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.fz.mapper.BookMapper">
<resultMap id="bk" type="book">
<id column="book_id" property="id"/>
<result property="name" column="book_name"/>
<result property="price" column="book_price"/>
</resultMap>
<select id="queryAll" resultType="book" resultMap="bk">
select * from book
</select>
<select id="page" parameterType="map" resultType="book">
select * from book limit #{start},#{pagesize}
</select>
<select id="queryById" resultType="book" statementType="PREPARED">
select * from book where id = #{id}
</select>
<delete id="delete" statementType="PREPARED">
delete from book
</delete>
<delete id="deleteById" parameterType="int" statementType="PREPARED">
delete from book where id = #{id}
</delete>
<insert id="add" parameterType="book">
insert into book values(null,#{name},#{price})
</insert>
<insert id="save" parameterType="map">
insert into book values(null,#{name},#{price})
</insert>
<update id="update" parameterType="book">
update book set name=#{name},price=#{price} where id=#{id}
</update>
<update id="updateById" parameterType="map">
update book set name=#{name},price=#{price} where id=#{id}
</update>
<update id="updateByName" parameterType="map">
update book set price=#{price} where name=#{name}
</update>
</mapper>
<resultMap id="bk" type="book">
<id column="book_id" property="id"/>
<result property="name" column="book_name"/>
<result property="price" column="book_price"/>
</resultMap>
<select id="queryAll" resultType="book" resultMap="bk">
select * from book
</select>
标签:res bsp tab start _id book query engine pac
原文地址:http://www.cnblogs.com/Mkady/p/7055949.html