zoukankan      html  css  js  c++  java
  • mybatis mapper配置文件 CustomerMapper.xml

    Dao

    @Repository
    public interface CustomerDAO {
        public void create(CustomerModel cm);
        public void update(CustomerModel cm);
        public void delete(CustomerModel cm);
        
        public CustomerModel getByUuid(int uuid);
        
        public List<CustomerModel> getByCondition(CustomerQueryModel cqm);
                
    }

    实体

    public class CustomerModel {
        private Integer uuid;
        private String customerId;
        private String pwd;
        private String showName;
        private String trueName;
        private String registerTime;

    }

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.exayong.architecture1.customermgr.dao.CustomerDAO">
        <insert id="create" parameterType="CM">
            insert into
            tbl_customer(customerId,pwd,showName,trueName,registerTime)values(#{customerId},#{pwd},#{showName},#{trueName},#{registerTime})
        </insert>
        <update id="update" parameterType="CM">
            update tbl_customer set
            customerId=#{customerId},pwd=#{pwd},showName=#{showName},trueName=#{trueName},registerTime=#{registerTime}
            where uuid=#{uuid}
        </update>

        <delete id="delete" parameterType="Int">
            delete from tbl customer where uuid=#{uuid}

        </delete>

        <select id="getByUuid" parameterType="Int" resultType="CM">
            select * from tbl_customer where uuid=#{_uuid}

        </select>
        <select id="getByCondition" parameterType="CQM" resultType="CM">
            select * from tbl_customer
            <where>
                <if test="uuid=null &amp;&amp; uuid >0">
                    and uuid=#{_uuid}

                </if>
                <if test="customerId=null">
                    and customerId=#{customerId}

                </if>
                <if test="showName=null">
                    and showName=#{showName}
                </if>
            </where>

        </select>
    </mapper>

  • 相关阅读:
    hdoj_1800Flying to the Mars
    SPFA模版
    树状数组
    hdoj_1385Minimum Transport Cost
    hdoj_2112
    hdoj_3665Seaside
    Java的垃圾回收之算法
    Oracle和MySQL、PostgreSQL特性对比
    什么是java对象的强、软、弱和虚引用
    线程池(java.util.concurrent.ThreadPoolExecutor)的使用(一)
  • 原文地址:https://www.cnblogs.com/exayong/p/6507370.html
Copyright © 2011-2022 走看看