Mybatis

Mybatis介绍:

https://www.cnblogs.com/nickup/p/9726433.html

Mybatis实现乐观锁version并实现回滚

version增加数据库版本标识,version一般为数值或时间戳

https://blog.csdn.net/qq_32923745/article/details/88800060

https://blog.csdn.net/hedy17/article/details/79376611

1、问题:There is no getter for property named 'param' in 'class java.lang.String'

DaoImpl:

@Override
    public List<Map<String, Object>> getSelectByDictCode(String param) {
        // TODO 自动生成的方法存根
        return session.selectList("getSelectByDictCode", param);
    }

参数:parameterType="string"

<select id="getSelectByDictCode" parameterType="string" resultType="map">
        select
            dict_lable    as   "key",
            dict_value  as   "value"
        from tb_dict
        where dict_status = '1'
        <if test=" param != null and param != ''">
          and dict_code = #{param}
        </if>
        order by dict_sort asc
    </select>

在if test=验证的时候发生的 “There is no getter for property named in ‘class java.lang.String’”,需要使用

_parameter
<select id="getSelectByDictCode" parameterType="string" resultType="map">
        select
            dict_lable    as   "key",
            dict_value  as   "value"
        from tb_dict
        where dict_status = '1'
        <if test=" _parameter != null and _parameter != ''">
          and dict_code = #{param}
        </if>
        order by dict_sort asc
    </select>

 2、<choose >标签

choose (when,otherwize) ,相当于java 语言中的 switch ,与 jstl 中 的 choose 很类似。

test="conferenceSystemId != null and conferenceSystemId == '2'.toString()"

<select id="getUserByCommitteeId" parameterType="map" resultType="user">
        <choose>
             <when test="committee_id != null and committee_id != ''">
                      select tu.* from tb_committee_rule tcr ,tb_user tu 
                      where tcr.user_id = tu.id and tcr.committee_id = #{committee_id}
             </when>
<otherwise> select tu.* from tb_user tu,tb_user_role tur where tu.id = tur.user_id and tur.role_id = (select tr.id from tb_role tr where tr.name = '委员') </otherwise> </choose> </select>

 3、无法使用 <= 等符号

  解决方式:<![CDATA[ <= ]]>

原文地址:https://www.cnblogs.com/lijianda/p/8920205.html