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>
  • 相关阅读:
    python入坑级
    nginx配置文件详解
    nginx看端口使用情况
    linux安装nginx
    linux安装jdk1.7
    linux设置tomcat开机启动
    redis master配置了密码进行主从同步
    linux搭建mysql 5.6.28
    linux搭建redis数据库
    找出一组数里出现频率最高的3个数(1.3)
  • 原文地址:https://www.cnblogs.com/CESC4/p/7306874.html
Copyright © 2011-2022 走看看