zoukankan      html  css  js  c++  java
  • Mybatis传参方式

    • 传递多个参数的四种方式:
    • 顺序传参:public User selectUser(String name,int deptId); <select id="selectUser" resultType="user">select * from user where user_name=#{0} and dept_id = #{1}</select> #{}里面的数字代表你穿如参数的顺序.不建议使用.sql层表达不直观
    • @Param 注解传参:public User selectUser(@Param("userName")String name,@Param("deptId")int deptId); <select id="selectUser" resultType="user">select * from user where user_name=#{userName} and dept_id = #{deptId}</select> #{}里面的名称对应的是注解@Param 括号中修饰的名称,这种情况在参数不多的情况下比较直观,推荐之用
    • Map传参法:public User selectUser(Map<String,Object> params); <select id="selectUser" resultType="user" parameterType="map">select * from user where user_name=#{userName} and dept_id = #{deptId}</select> #{}里面的名称对应的是Map里面的key名称,这种方法适合多个参数,且参数易变能灵活传递的情况
    • Java Bean传参数::public User selectUser(User user); <select id="selectUser" resultType="user" parameterType="user">select * from user where user_name=#{userName} and dept_id = #{deptId}</select> #{}里面的名称对应的是 User类里面的成员属性。 这种方法很直观,但需要建一个实体类,扩展不容易,需要加属性,看情况使用
    • 转载(Hollis)
  • 相关阅读:
    关于python3.x语法
    linux简单的安全防护
    hydra(爆破神器)
    扫描Linux服务器查找恶意软件和rootkit的一款工具
    chm 已取消到该网页的导航,打不开!
    android:activity知识点
    C# Mutex对象的使用
    惯性质量与引力质量的联系
    c# timer使用
    weiFenLuo.winFormsUI.Docking.dll学习
  • 原文地址:https://www.cnblogs.com/wadmwz/p/8971928.html
Copyright © 2011-2022 走看看