zoukankan      html  css  js  c++  java
  • Mybatis----Mapper配置文件

     1 <?xml version="1.0" encoding="UTF-8" ?>
     2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     3         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
     4 
     5 <mapper namespace="com.orma.mapper.LwlaMapper">
     6 
     7     <!--    插入:使用对象-->
     8     <insert id="insertLwla" parameterType="Lwla" >
     9             INSERT INTO lwla(lwla, lwlb, lwlc)
    10             VALUES(#{lwla}, #{lwlb}, #{lwlc})
    11     </insert>
    12 
    13     <!--插入:使用HashMap-->
    14     <insert id="insertHashMap" parameterType="Map">
    15         insert into Lwla(lwla,lwlb,lwlc)
    16         values(#{Lwla.lwla},#{Lwla.lwlb},#{Lwla.lwlc})
    17     </insert>
    18 
    19     <!--查询:使用Map 完整查询-->
    20     <select id="getUserInfo" resultType="Map">
    21         select * from Lwla
    22     </select>
    23 
    24 
    25     <!--查询一个结果,select语句可使用-->
    26     <resultMap id="LwlaResultSet" type="com.orma.model.Lwla">
    27         <id property="lwla" column="lwla"/>
    28         <result property="lwlb" column="lwlb"/>
    29         <result property="lwlc" column="lwlc"/>
    30     </resultMap>
    31     <select id="getLwla" resultMap="LwlaResultSet" parameterType="Lwla">
    32             select * from Lwla where lwlc like '%${lwlc}%'
    33     </select>
    34 
    35 
    36     <!--    查询:Map,like模糊查询-->
    37     <select id="getLwla2" resultType="Map" parameterType="Map">
    38             select * from Lwla where lwlc like '%${lwlc}%'
    39     </select>
    40 
    41 
    42     <!--    查询一条结果  参数:int-->
    43     <select id="getLwla3" resultType="Lwla" parameterType="int">
    44             select  *  from Lwla where lwla=#{anyname}
    45     </select>
    46 
    47 
    48     <!--删除  参数:int-->
    49     <delete id="deleteLwla" parameterType="int">
    50             DELETE FROM Lwla WHERE lwla = #{anyname}
    51     </delete>
    52 
    53 
    54     <!--   修改:使用Map-->
    55     <update id="updateLwla" parameterType="Map">
    56                 UPDATE Lwla
    57                 SET
    58                 lwla=#{Lwla.lwla},lwlb=#{Lwla.lwlb},lwlc=#{Lwla.lwlc}
    59                 WHERE
    60                 lwla = #{oldlwla}
    61     </update>
    62 
    63 </mapper>
    原创文章,转载请说明出处,谢谢合作
  • 相关阅读:
    EV: There is no source code available for the current location.
    EV: 致新教育萤火虫父母们
    DEL: 2012年每月花销
    DEL: 博客分类规则
    java编程规范
    maven随笔
    JMS组成结构与特点
    activemq 的简单使用
    activeMQ安装与访问
    java8 stream
  • 原文地址:https://www.cnblogs.com/lwl80/p/13631516.html
Copyright © 2011-2022 走看看