zoukankan      html  css  js  c++  java
  • MyBaits 常见面试题

    1 在mapper中如何传递多个参数?

    第1种:

    //DAO层的函数
    
    Public UserselectUser(String name,String area);  
    //对应的xml,#{0}代表接收的是dao层中的第一个参数,#{1}代表dao层中第二参数,更多参数一致往后加即可。
    
    <select id="selectUser"resultMap="BaseResultMap">  
        select *  fromuser_user_t   whereuser_name = #{0} anduser_area=#{1}  
    </select>  

    第2种: 使用 @param 注解:

        import org.apache.ibatis.annotations.param; 
            public interface usermapper { 
             user selectuser(@param(“username”) string username, 
             @param(“hashedpassword”) string hashedpassword); 
            }
    然后,就可以在xml像下面这样使用(推荐封装为一个map,作为单个参数传递给mapper): 
        <select id=”selectuser” resulttype=”user”> 
             select id, username, hashedpassword 
             from some_table 
             where username = #{username} 
             and hashedpassword = #{hashedpassword} 
        </select>

    第2种: 使用map:

    <select id="getSysInfo" parameterType="java.util.Map" resultType="SysWeb">
      select t.sysSiteId, t.siteName, t1.mzNum as siteTagNum, t1.mzName as siteTag, t.url, t.iconPath
       from TD_WEB_SYSSITE t
       left join TD_MZ_MZDY t1 on t1.mzNum = t.siteTag and t1.mzType = 10
       WHERE t.siteTag = #{siteTag } 
       and t.sysSiteId not in 
       <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
           #{item}
       </foreach>
     </select>

     2 mybaits in查询

      

     
  • 相关阅读:
    深入浅出HTTP请求(转自http://www.cnblogs.com/yin-jingyu/archive/2011/08/01/2123548.html)
    IOS定位
    webView(简单的浏览器)
    Get&Post登录
    IOS多媒体
    IOS VFL屏幕自适应
    IOS中在自定义控件(非视图控制器)的视图跳转中 代理方法与代码块的比较
    单例设计的定义
    动画
    多线程
  • 原文地址:https://www.cnblogs.com/shujiying/p/10232979.html
Copyright © 2011-2022 走看看