update dao

This commit is contained in:
shuzheng 2016-11-14 22:37:46 +08:00
parent d8b6098bc8
commit 316f2a348b
8 changed files with 153 additions and 151 deletions

View File

@ -10,7 +10,7 @@ public interface BookMapper {
int deleteByExample(BookExample example);
int deleteByPrimaryKey(Integer id);
int deleteByPrimaryKey(Integer bookId);
int insert(Book record);
@ -18,7 +18,7 @@ public interface BookMapper {
List<Book> selectByExample(BookExample example);
Book selectByPrimaryKey(Integer id);
Book selectByPrimaryKey(Integer bookId);
int updateByExampleSelective(@Param("record") Book record, @Param("example") BookExample example);

View File

@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zheng.cms.dao.mapper.BookMapper" >
<resultMap id="BaseResultMap" type="com.zheng.cms.dao.model.Book" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="userid" property="userid" jdbcType="INTEGER" />
<id column="book_id" property="bookId" jdbcType="INTEGER" />
<result column="user_id" property="userId" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
</resultMap>
<sql id="Example_Where_Clause" >
@ -65,7 +65,7 @@
</where>
</sql>
<sql id="Base_Column_List" >
id, userid, name
book_id, user_id, name
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.zheng.cms.dao.model.BookExample" >
select
@ -93,11 +93,11 @@
select
<include refid="Base_Column_List" />
from book
where id = #{id,jdbcType=INTEGER}
where book_id = #{bookId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from book
where id = #{id,jdbcType=INTEGER}
where book_id = #{bookId,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.dao.model.BookExample" >
delete from book
@ -106,28 +106,30 @@
</if>
</delete>
<insert id="insert" parameterType="com.zheng.cms.dao.model.Book" >
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into book (userid, name)
values (#{userid,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR})
insert into book (book_id, user_id, name
)
values (#{bookId,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.zheng.cms.dao.model.Book" >
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into book
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="userid != null" >
userid,
<if test="bookId != null" >
book_id,
</if>
<if test="userId != null" >
user_id,
</if>
<if test="name != null" >
name,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="userid != null" >
#{userid,jdbcType=INTEGER},
<if test="bookId != null" >
#{bookId,jdbcType=INTEGER},
</if>
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
@ -143,11 +145,11 @@
<update id="updateByExampleSelective" parameterType="map" >
update book
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
<if test="record.bookId != null" >
book_id = #{record.bookId,jdbcType=INTEGER},
</if>
<if test="record.userid != null" >
userid = #{record.userid,jdbcType=INTEGER},
<if test="record.userId != null" >
user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.name != null" >
name = #{record.name,jdbcType=VARCHAR},
@ -159,8 +161,8 @@
</update>
<update id="updateByExample" parameterType="map" >
update book
set id = #{record.id,jdbcType=INTEGER},
userid = #{record.userid,jdbcType=INTEGER},
set book_id = #{record.bookId,jdbcType=INTEGER},
user_id = #{record.userId,jdbcType=INTEGER},
name = #{record.name,jdbcType=VARCHAR}
<if test="_parameter != null" >
<include refid="Update_By_Example_Where_Clause" />
@ -169,20 +171,20 @@
<update id="updateByPrimaryKeySelective" parameterType="com.zheng.cms.dao.model.Book" >
update book
<set >
<if test="userid != null" >
userid = #{userid,jdbcType=INTEGER},
<if test="userId != null" >
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
where book_id = #{bookId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.dao.model.Book" >
update book
set userid = #{userid,jdbcType=INTEGER},
set user_id = #{userId,jdbcType=INTEGER},
name = #{name,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
where book_id = #{bookId,jdbcType=INTEGER}
</update>
<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
</mapper>

View File

@ -10,7 +10,7 @@ public interface UserMapper {
int deleteByExample(UserExample example);
int deleteByPrimaryKey(Integer id);
int deleteByPrimaryKey(Integer userId);
int insert(User record);
@ -20,7 +20,7 @@ public interface UserMapper {
List<User> selectByExample(UserExample example);
User selectByPrimaryKey(Integer id);
User selectByPrimaryKey(Integer userId);
int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);

View File

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.zheng.cms.dao.mapper.UserMapper" >
<resultMap id="BaseResultMap" type="com.zheng.cms.dao.model.User" >
<id column="id" property="id" jdbcType="INTEGER" />
<id column="user_id" property="userId" jdbcType="INTEGER" />
<result column="username" property="username" jdbcType="VARCHAR" />
<result column="password" property="password" jdbcType="VARCHAR" />
<result column="nickname" property="nickname" jdbcType="VARCHAR" />
@ -71,7 +71,7 @@
</where>
</sql>
<sql id="Base_Column_List" >
id, username, password, nickname, sex, ctime
user_id, username, password, nickname, sex, ctime
</sql>
<sql id="Blob_Column_List" >
content
@ -120,11 +120,11 @@
,
<include refid="Blob_Column_List" />
from user
where id = #{id,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from user
where id = #{id,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.zheng.cms.dao.model.UserExample" >
delete from user
@ -133,22 +133,19 @@
</if>
</delete>
<insert id="insert" parameterType="com.zheng.cms.dao.model.User" >
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into user (username, password, nickname,
sex, ctime, content
)
values (#{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{nickname,jdbcType=VARCHAR},
#{sex,jdbcType=INTEGER}, #{ctime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR}
)
insert into user (user_id, username, password,
nickname, sex, ctime,
content)
values (#{userId,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR},
#{nickname,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER}, #{ctime,jdbcType=BIGINT},
#{content,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.zheng.cms.dao.model.User" >
<selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
SELECT LAST_INSERT_ID()
</selectKey>
insert into user
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="userId != null" >
user_id,
</if>
<if test="username != null" >
username,
</if>
@ -169,6 +166,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="userId != null" >
#{userId,jdbcType=INTEGER},
</if>
<if test="username != null" >
#{username,jdbcType=VARCHAR},
</if>
@ -198,8 +198,8 @@
<update id="updateByExampleSelective" parameterType="map" >
update user
<set >
<if test="record.id != null" >
id = #{record.id,jdbcType=INTEGER},
<if test="record.userId != null" >
user_id = #{record.userId,jdbcType=INTEGER},
</if>
<if test="record.username != null" >
username = #{record.username,jdbcType=VARCHAR},
@ -226,7 +226,7 @@
</update>
<update id="updateByExampleWithBLOBs" parameterType="map" >
update user
set id = #{record.id,jdbcType=INTEGER},
set user_id = #{record.userId,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR},
nickname = #{record.nickname,jdbcType=VARCHAR},
@ -239,7 +239,7 @@
</update>
<update id="updateByExample" parameterType="map" >
update user
set id = #{record.id,jdbcType=INTEGER},
set user_id = #{record.userId,jdbcType=INTEGER},
username = #{record.username,jdbcType=VARCHAR},
password = #{record.password,jdbcType=VARCHAR},
nickname = #{record.nickname,jdbcType=VARCHAR},
@ -271,7 +271,7 @@
content = #{content,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.zheng.cms.dao.model.User" >
update user
@ -281,7 +281,7 @@
sex = #{sex,jdbcType=INTEGER},
ctime = #{ctime,jdbcType=BIGINT},
content = #{content,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.zheng.cms.dao.model.User" >
update user
@ -290,7 +290,7 @@
nickname = #{nickname,jdbcType=VARCHAR},
sex = #{sex,jdbcType=INTEGER},
ctime = #{ctime,jdbcType=BIGINT}
where id = #{id,jdbcType=INTEGER}
where user_id = #{userId,jdbcType=INTEGER}
</update>
<cache type="org.mybatis.caches.ehcache.LoggingEhcache" />
</mapper>

View File

@ -3,28 +3,28 @@ package com.zheng.cms.dao.model;
import java.io.Serializable;
public class Book implements Serializable {
private Integer id;
private Integer bookId;
private Integer userid;
private Integer userId;
private String name;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
public Integer getBookId() {
return bookId;
}
public void setId(Integer id) {
this.id = id;
public void setBookId(Integer bookId) {
this.bookId = bookId;
}
public Integer getUserid() {
return userid;
public Integer getUserId() {
return userId;
}
public void setUserid(Integer userid) {
this.userid = userid;
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getName() {
@ -41,8 +41,8 @@ public class Book implements Serializable {
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userid=").append(userid);
sb.append(", bookId=").append(bookId);
sb.append(", userId=").append(userId);
sb.append(", name=").append(name);
sb.append("]");
return sb.toString();
@ -60,8 +60,8 @@ public class Book implements Serializable {
return false;
}
Book other = (Book) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUserid() == null ? other.getUserid() == null : this.getUserid().equals(other.getUserid()))
return (this.getBookId() == null ? other.getBookId() == null : this.getBookId().equals(other.getBookId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getName() == null ? other.getName() == null : this.getName().equals(other.getName()));
}
@ -69,8 +69,8 @@ public class Book implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserid() == null) ? 0 : getUserid().hashCode());
result = prime * result + ((getBookId() == null) ? 0 : getBookId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
return result;
}

View File

@ -124,123 +124,123 @@ public class BookExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
public Criteria andBookIdIsNull() {
addCriterion("book_id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
public Criteria andBookIdIsNotNull() {
addCriterion("book_id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
public Criteria andBookIdEqualTo(Integer value) {
addCriterion("book_id =", value, "bookId");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
public Criteria andBookIdNotEqualTo(Integer value) {
addCriterion("book_id <>", value, "bookId");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
public Criteria andBookIdGreaterThan(Integer value) {
addCriterion("book_id >", value, "bookId");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
public Criteria andBookIdGreaterThanOrEqualTo(Integer value) {
addCriterion("book_id >=", value, "bookId");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
public Criteria andBookIdLessThan(Integer value) {
addCriterion("book_id <", value, "bookId");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
public Criteria andBookIdLessThanOrEqualTo(Integer value) {
addCriterion("book_id <=", value, "bookId");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
public Criteria andBookIdIn(List<Integer> values) {
addCriterion("book_id in", values, "bookId");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
public Criteria andBookIdNotIn(List<Integer> values) {
addCriterion("book_id not in", values, "bookId");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
public Criteria andBookIdBetween(Integer value1, Integer value2) {
addCriterion("book_id between", value1, value2, "bookId");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
public Criteria andBookIdNotBetween(Integer value1, Integer value2) {
addCriterion("book_id not between", value1, value2, "bookId");
return (Criteria) this;
}
public Criteria andUseridIsNull() {
addCriterion("userid is null");
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andUseridIsNotNull() {
addCriterion("userid is not null");
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andUseridEqualTo(Integer value) {
addCriterion("userid =", value, "userid");
public Criteria andUserIdEqualTo(Integer value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andUseridNotEqualTo(Integer value) {
addCriterion("userid <>", value, "userid");
public Criteria andUserIdNotEqualTo(Integer value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andUseridGreaterThan(Integer value) {
addCriterion("userid >", value, "userid");
public Criteria andUserIdGreaterThan(Integer value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andUseridGreaterThanOrEqualTo(Integer value) {
addCriterion("userid >=", value, "userid");
public Criteria andUserIdGreaterThanOrEqualTo(Integer value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andUseridLessThan(Integer value) {
addCriterion("userid <", value, "userid");
public Criteria andUserIdLessThan(Integer value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andUseridLessThanOrEqualTo(Integer value) {
addCriterion("userid <=", value, "userid");
public Criteria andUserIdLessThanOrEqualTo(Integer value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andUseridIn(List<Integer> values) {
addCriterion("userid in", values, "userid");
public Criteria andUserIdIn(List<Integer> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andUseridNotIn(List<Integer> values) {
addCriterion("userid not in", values, "userid");
public Criteria andUserIdNotIn(List<Integer> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andUseridBetween(Integer value1, Integer value2) {
addCriterion("userid between", value1, value2, "userid");
public Criteria andUserIdBetween(Integer value1, Integer value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andUseridNotBetween(Integer value1, Integer value2) {
addCriterion("userid not between", value1, value2, "userid");
public Criteria andUserIdNotBetween(Integer value1, Integer value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}

View File

@ -3,7 +3,7 @@ package com.zheng.cms.dao.model;
import java.io.Serializable;
public class User implements Serializable {
private Integer id;
private Integer userId;
private String username;
@ -19,12 +19,12 @@ public class User implements Serializable {
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
public Integer getUserId() {
return userId;
}
public void setId(Integer id) {
this.id = id;
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUsername() {
@ -81,7 +81,7 @@ public class User implements Serializable {
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", userId=").append(userId);
sb.append(", username=").append(username);
sb.append(", password=").append(password);
sb.append(", nickname=").append(nickname);
@ -104,7 +104,7 @@ public class User implements Serializable {
return false;
}
User other = (User) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
return (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getNickname() == null ? other.getNickname() == null : this.getNickname().equals(other.getNickname()))
@ -117,7 +117,7 @@ public class User implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getNickname() == null) ? 0 : getNickname().hashCode());

View File

@ -124,63 +124,63 @@ public class UserExample {
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
public Criteria andUserIdIsNull() {
addCriterion("user_id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
public Criteria andUserIdIsNotNull() {
addCriterion("user_id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
public Criteria andUserIdEqualTo(Integer value) {
addCriterion("user_id =", value, "userId");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
public Criteria andUserIdNotEqualTo(Integer value) {
addCriterion("user_id <>", value, "userId");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
public Criteria andUserIdGreaterThan(Integer value) {
addCriterion("user_id >", value, "userId");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
public Criteria andUserIdGreaterThanOrEqualTo(Integer value) {
addCriterion("user_id >=", value, "userId");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
public Criteria andUserIdLessThan(Integer value) {
addCriterion("user_id <", value, "userId");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
public Criteria andUserIdLessThanOrEqualTo(Integer value) {
addCriterion("user_id <=", value, "userId");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
public Criteria andUserIdIn(List<Integer> values) {
addCriterion("user_id in", values, "userId");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
public Criteria andUserIdNotIn(List<Integer> values) {
addCriterion("user_id not in", values, "userId");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
public Criteria andUserIdBetween(Integer value1, Integer value2) {
addCriterion("user_id between", value1, value2, "userId");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
public Criteria andUserIdNotBetween(Integer value1, Integer value2) {
addCriterion("user_id not between", value1, value2, "userId");
return (Criteria) this;
}