zoukankan      html  css  js  c++  java
  • mybais 的映射文件,需要从poviderDao.java 的一个 方法 public getProvidersFactors(参数 ) 中传入多个参数到providerDao.xml中的两种方法

    方法一:

      直接以对象的整体的形式去传入到xml文件中,当然这时候用过满足的条件是:你所想传入的所有的参数,应该都是包含在一个对象中的,此时可以以对象的形式去传入到xml中

    如下图示例

    实体类
        private String id;
        private String companyName;
        private String managerName;
        private String phone;
        private String address;
        private String type;
        
    #ProviderDao.java文件  传入的是一个对象
    
    
    public List<Provider> getProvidersFactors(Provider provider);
    xml映射文件 ProviderDao.xml
    <select id="getProvidersFactors" parameterType="com.thinkgem.jeesite.modules.goodsmanage.entity.Provider" resultType="com.thinkgem.jeesite.modules.goodsmanage.entity.Provider">
        select
        <include refid="providerColumns"></include>
        from ma_provider p
        <where>
            1=1
            <if    test="id !=null and id !=''">
                and p.id = #{id}  
            </if>
            <if    test="companyName !=null and companyName !=''">
                and p.companyName = #{companyName} 
    </if> <if test="address !=null and address !=''"> and p.address = #{address} </if> </where> </select>    
    

    方法二:

      直接的传入多个参数,但是此时需要的是@Param注解的配合使用(但是这种方式只适合传输两个到三个参数的时候,当参数的数目过多的时候,此方法太麻烦了!!)

    示例

    providerDao.java文件  传入的是多个参数

    public List<Provider> getProvidersFactors(@Param("id")String id ,@Param("companyName")String companyName,@Param("address ")String address );

    providerDao.xml文件

    <select id="getProvidersFactors" parameterType="com.thinkgem.jeesite.modules.goodsmanage.entity.Provider" resultType="com.thinkgem.jeesite.modules.goodsmanage.entity.Provider">
        select
        <include refid="providerColumns"></include>
        from ma_provider p
        <where>
            1=1
            <if    test="id !=null and id !=''">
                and p.id = #{id}  
            </if>
            <if    test="companyName !=null and companyName !=''">
                and p.companyName = #{companyName} 
    </if> <if test="address !=null and address !=''"> and p.address = #{address} </if> </where> </select>    
  • 相关阅读:
    clickhouse 多数据源
    maven-dependency-plugin maven-assembly-plugin
    maven shade plugin
    远程服务器,无法复制粘贴 (通过mstsc复制粘贴失败需要重新启动RDP剪切板监视程序rdpclip.exe)
    Mysql导入大sql文件方法
    MySQL5.7更新json类型字段中的某个key的值 函数json_replace()
    mysq json类型
    增强mybatis-plus的typeHandler,可以支持List<T> 中嵌套对象
    Windows中查看端口占用及关闭对应进程
    Hibernate中继承体现
  • 原文地址:https://www.cnblogs.com/isme-zjh/p/12611549.html
Copyright © 2011-2022 走看看