zoukankan      html  css  js  c++  java
  • 【Mybatis】传Map与传String

    
    
    ShipStatic ship=shipService.getShipInfoBymmsi(mmsi);
    public interface ShipStaticMapper extends Mapper<ShipStatic> {
    ShipStatic getShipinfoBymmsi(String mmsi);
    }
    <select id="getShipinfoBymmsi" parameterType="string" resultMap="BaseResultMap">
    SELECT
    *
    FROM
    ship_static
    <where>
    mmsi = #{mmsi}
    </where>
    </select>


    public interface ShipImageMapper extends Mapper<ShipImage> {
    List<ShipImage> getShipImageByMmsi(String mmsi);
    List<ShipImage> getImagesByMMSI(Map<String,Object> params);
    }
    两种不同的方式:
    1.传Map
     1 Map<String,Object> params=new HashMap<String, Object>();
     2 params.put("mmsi",mmsi);
     3 List<ShipImage> imageList=shipImageMapper.getImagesByMMSI(params);
     4 
     5 <select id="getImagesByMMSI" parameterType="java.util.Map" resultMap="BaseResultMap">
     6    SELECT a.*  from ship_image a
     7     <where>
     8         <if test="mmsi != null and mmsi!=''">
     9             and a.ship_id = #{mmsi}
    10         </if>
    11     </where>
    12 </select>
    2.传String
     1 List<ShipImage> images = shipImageMapper.getShipImageBymmsi(mmsi);
     2 
     3 <select id="getShipImageByMmsi" parameterType="string" resultMap="BaseResultMap">
     4     SELECT
     5     *
     6     FROM
     7     ship_image
     8     <where>
     9         ship_id = #{mmsi}
    10     </where>
    11 </select>
  • 相关阅读:
    虚拟机设置与主机同网段的IP
    centos8 安装docker
    postgresql10 修改密码及远程访问
    centos7 安装pycharm
    centos7安装Python
    docker容器固定ip
    centos7 redis 自启动
    centos7 nginx添加自启
    docker 容器时间不正确的修改方法
    浅谈麦克斯韦方程组与相对论
  • 原文地址:https://www.cnblogs.com/CESC4/p/7306874.html
Copyright © 2011-2022 走看看