ReviewMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.how2java.tmall.mapper.ReviewMapper">
  4. <resultMap id="BaseResultMap" type="com.how2java.tmall.pojo.Review">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="content" jdbcType="VARCHAR" property="content" />
  7. <result column="uid" jdbcType="INTEGER" property="uid" />
  8. <result column="pid" jdbcType="INTEGER" property="pid" />
  9. <result column="createDate" jdbcType="TIMESTAMP" property="createDate" />
  10. </resultMap>
  11. <sql id="Example_Where_Clause">
  12. <where>
  13. <foreach collection="oredCriteria" item="criteria" separator="or">
  14. <if test="criteria.valid">
  15. <trim prefix="(" prefixOverrides="and" suffix=")">
  16. <foreach collection="criteria.criteria" item="criterion">
  17. <choose>
  18. <when test="criterion.noValue">
  19. and ${criterion.condition}
  20. </when>
  21. <when test="criterion.singleValue">
  22. and ${criterion.condition} #{criterion.value}
  23. </when>
  24. <when test="criterion.betweenValue">
  25. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  26. </when>
  27. <when test="criterion.listValue">
  28. and ${criterion.condition}
  29. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  30. #{listItem}
  31. </foreach>
  32. </when>
  33. </choose>
  34. </foreach>
  35. </trim>
  36. </if>
  37. </foreach>
  38. </where>
  39. </sql>
  40. <sql id="Base_Column_List">
  41. id, content, uid, pid, createDate
  42. </sql>
  43. <select id="selectByExample" parameterType="com.how2java.tmall.pojo.ReviewExample" resultMap="BaseResultMap">
  44. select
  45. <if test="distinct">
  46. distinct
  47. </if>
  48. 'false' as QUERYID,
  49. <include refid="Base_Column_List" />
  50. from review
  51. <if test="_parameter != null">
  52. <include refid="Example_Where_Clause" />
  53. </if>
  54. <if test="orderByClause != null">
  55. order by ${orderByClause}
  56. </if>
  57. </select>
  58. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  59. select
  60. <include refid="Base_Column_List" />
  61. from review
  62. where id = #{id,jdbcType=INTEGER}
  63. </select>
  64. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  65. delete from review
  66. where id = #{id,jdbcType=INTEGER}
  67. </delete>
  68. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Review" useGeneratedKeys="true">
  69. insert into review (content, uid, pid,
  70. createDate)
  71. values (#{content,jdbcType=VARCHAR}, #{uid,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER},
  72. #{createDate,jdbcType=TIMESTAMP})
  73. </insert>
  74. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Review" useGeneratedKeys="true">
  75. insert into review
  76. <trim prefix="(" suffix=")" suffixOverrides=",">
  77. <if test="content != null">
  78. content,
  79. </if>
  80. <if test="uid != null">
  81. uid,
  82. </if>
  83. <if test="pid != null">
  84. pid,
  85. </if>
  86. <if test="createDate != null">
  87. createDate,
  88. </if>
  89. </trim>
  90. <trim prefix="values (" suffix=")" suffixOverrides=",">
  91. <if test="content != null">
  92. #{content,jdbcType=VARCHAR},
  93. </if>
  94. <if test="uid != null">
  95. #{uid,jdbcType=INTEGER},
  96. </if>
  97. <if test="pid != null">
  98. #{pid,jdbcType=INTEGER},
  99. </if>
  100. <if test="createDate != null">
  101. #{createDate,jdbcType=TIMESTAMP},
  102. </if>
  103. </trim>
  104. </insert>
  105. <update id="updateByPrimaryKeySelective" parameterType="com.how2java.tmall.pojo.Review">
  106. update review
  107. <set>
  108. <if test="content != null">
  109. content = #{content,jdbcType=VARCHAR},
  110. </if>
  111. <if test="uid != null">
  112. uid = #{uid,jdbcType=INTEGER},
  113. </if>
  114. <if test="pid != null">
  115. pid = #{pid,jdbcType=INTEGER},
  116. </if>
  117. <if test="createDate != null">
  118. createDate = #{createDate,jdbcType=TIMESTAMP},
  119. </if>
  120. </set>
  121. where id = #{id,jdbcType=INTEGER}
  122. </update>
  123. <update id="updateByPrimaryKey" parameterType="com.how2java.tmall.pojo.Review">
  124. update review
  125. set content = #{content,jdbcType=VARCHAR},
  126. uid = #{uid,jdbcType=INTEGER},
  127. pid = #{pid,jdbcType=INTEGER},
  128. createDate = #{createDate,jdbcType=TIMESTAMP}
  129. where id = #{id,jdbcType=INTEGER}
  130. </update>
  131. </mapper>