【service調用dao層傳參的三種方式】


第一種方案:默認數組角標:

service

Public User selectUser(String name,String area);

 

mapper:

< select id= "selectUser" resultMap= "BaseResultMap" >
     select  from user_user_t   where user_name = #{0} and user_area=#{1}
</ select >
 
第二種方案:map集合傳參:
 
service:
Map paramMap=new hashMap();
paramMap.put(“userName”,”對應具體的參數值”);
paramMap.put(“userArea”,”對應具體的參數值”);
Public User selectUser(Map paramMap);
 
mapper:
< select id= " selectUser" resultMap= "BaseResultMap" >
    select  from user_user_t   where user_name = #{userName,jdbcType= VARCHAR } and user_area=#{userArea,jdbcType= VARCHAR }
</ select >
 
第三種方案:參數修正
service
Public User selectUser(@param(“userName”)Stringname,@param(“userArea”)String area);
 
mapper:
< select id= " selectUser" resultMap= "BaseResultMap" >
    select  from user_user_t   where user_name = #{userName,jdbcType= VARCHAR } and user_area=#{userArea,jdbcType= VARCHAR }
</ select >
 
 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM