CategoryMapper.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.CategoryMapper">
  4. <resultMap id="BaseResultMap" type="com.how2java.tmall.pojo.Category">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="name" jdbcType="VARCHAR" property="name" />
  7. </resultMap>
  8. <sql id="Example_Where_Clause">
  9. <where>
  10. <foreach collection="oredCriteria" item="criteria" separator="or">
  11. <if test="criteria.valid">
  12. <trim prefix="(" prefixOverrides="and" suffix=")">
  13. <foreach collection="criteria.criteria" item="criterion">
  14. <choose>
  15. <when test="criterion.noValue">
  16. and ${criterion.condition}
  17. </when>
  18. <when test="criterion.singleValue">
  19. and ${criterion.condition} #{criterion.value}
  20. </when>
  21. <when test="criterion.betweenValue">
  22. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  23. </when>
  24. <when test="criterion.listValue">
  25. and ${criterion.condition}
  26. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  27. #{listItem}
  28. </foreach>
  29. </when>
  30. </choose>
  31. </foreach>
  32. </trim>
  33. </if>
  34. </foreach>
  35. </where>
  36. </sql>
  37. <sql id="Base_Column_List">
  38. id, name
  39. </sql>
  40. <select id="selectByExample" parameterType="com.how2java.tmall.pojo.CategoryExample" resultMap="BaseResultMap">
  41. select
  42. <if test="distinct">
  43. distinct
  44. </if>
  45. 'false' as QUERYID,
  46. <include refid="Base_Column_List" />
  47. from category
  48. <if test="_parameter != null">
  49. <include refid="Example_Where_Clause" />
  50. </if>
  51. <if test="orderByClause != null">
  52. order by ${orderByClause}
  53. </if>
  54. </select>
  55. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  56. select
  57. <include refid="Base_Column_List" />
  58. from category
  59. where id = #{id,jdbcType=INTEGER}
  60. </select>
  61. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  62. delete from category
  63. where id = #{id,jdbcType=INTEGER}
  64. </delete>
  65. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Category" useGeneratedKeys="true">
  66. insert into category (name)
  67. values (#{name,jdbcType=VARCHAR})
  68. </insert>
  69. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.how2java.tmall.pojo.Category" useGeneratedKeys="true">
  70. insert into category
  71. <trim prefix="(" suffix=")" suffixOverrides=",">
  72. <if test="name != null">
  73. name,
  74. </if>
  75. </trim>
  76. <trim prefix="values (" suffix=")" suffixOverrides=",">
  77. <if test="name != null">
  78. #{name,jdbcType=VARCHAR},
  79. </if>
  80. </trim>
  81. </insert>
  82. <update id="updateByPrimaryKeySelective" parameterType="com.how2java.tmall.pojo.Category">
  83. update category
  84. <set>
  85. <if test="name != null">
  86. name = #{name,jdbcType=VARCHAR},
  87. </if>
  88. </set>
  89. where id = #{id,jdbcType=INTEGER}
  90. </update>
  91. <update id="updateByPrimaryKey" parameterType="com.how2java.tmall.pojo.Category">
  92. update category
  93. set name = #{name,jdbcType=VARCHAR}
  94. where id = #{id,jdbcType=INTEGER}
  95. </update>
  96. </mapper>