UserMapper.xml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
  3. "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
  4. <mapper namespace="org.example.mapper.UserMapper">
  5. <!--用户添加-->
  6. <!-- Integer insert(User user) -->
  7. <insert id="insert" useGeneratedKeys="true"
  8. keyProperty="id">
  9. INSERT INTO users(
  10. id,username,
  11. password
  12. )VALUES(
  13. #{id},#{username},
  14. #{password}
  15. )
  16. </insert>
  17. <!--查找用户名-->
  18. <!--User findByUsername(String username)-->
  19. <select id="findByUsername" resultType="org.example.entity.User">
  20. SELECT
  21. id,username,
  22. password
  23. FROM
  24. users
  25. WHERE
  26. username=#{username}
  27. </select>
  28. <!-- id查找用户 -->
  29. <!-- User findById(Integer id) -->
  30. <select id="findById" resultType="org.example.entity.User">
  31. SELECT
  32. id,username,
  33. password
  34. FROM
  35. users
  36. WHERE
  37. id=#{id}
  38. </select>
  39. </mapper>