mybatis使用對象傳入參數,sql中顯示的參數始終爲‘null’字符串 原

1.service層

  @Override
    public Role getRoleByType(String type,String orgId) {
        RoleType roleType = new RoleType();
        roleType.setOrg(orgId);
        roleType.setType(type);
        return roleMapper.getRoleByType(roleType);
    }

2.mapper.xml文件

 <select id="getRoleByType" resultMap="BaseResultMap" parameterType="com.inesa.usercenter.domain.vo.RoleType" >
    select
    <include refid="Base_Column_List" />
    from t_role
    where
    1=1
    <if test="org != null">
      and ORG_ID = #{org}
    </if>
    and type = #{type}
    <if test="org = null">
      and IS_SYSTEM = '1'
    </if>
  </select>

在service層的orgId、type都是有值的,但是始終查詢不到結果,查看sql發現,orgId的值始終爲‘null’字符串。困擾了好久,結果發現自己犯了一個非常低級的錯誤

這裏應該使用雙等號。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章