AccountDao.xml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="bank.dao.AccountDao">
  6. <sql id="selectAccountsWhere">
  7. <where>
  8. <if test="no!=null">
  9. no like "%${no}%"
  10. </if>
  11. <if test="name!=null">
  12. and name like "%${name}%"
  13. </if>
  14. </where>
  15. </sql>
  16. <select id="selectAccounts" parameterType="bank.model.Account" resultType="bank.model.Account">
  17. select * from account
  18. <include refid="selectAccountsWhere"/>
  19. </select>
  20. <insert id="insertAccount" parameterType="bank.model.Account">
  21. insert into account (no,name,balance) values (#{no},#{name},#{balance})
  22. </insert>
  23. <select id="getAccountByNo" parameterType="java.lang.String" resultType="bank.model.Account">
  24. select*from account where no=#{no}
  25. </select>
  26. <select id="getAccountByid" parameterType="java.lang.Integer" resultType="bank.model.Account">
  27. select * from account where id=#{id}
  28. </select>
  29. <update id="updateAccount" parameterType="bank.model.Account">
  30. update account set no=#{no},name=#{name},balance=#{balance} where id=#{id}
  31. </update>
  32. <delete id="deleteAccountById" parameterType="java.lang.Integer">
  33. delete from account where id=#{id}
  34. </delete>
  35. </mapper>