• Mybatis常用标签使用


    trim元素的主要功能是可以在自己包含的内容前加上某些前缀,也可以在其后加上某些后缀,与之对应的属性是prefix和suffix;可以把包含内容的首部某些内容覆盖,即忽略,也可以把尾部的某些内容覆盖,对应的属性是prefixOverrides和suffixOverrides;

    <insert id="operatorLog" parameterType="com.oa.model.wxlog.WxLog">
            INSERT INTO sdb_oa_operator_log
            <trim prefix="(" suffix=")" suffixOverrides="," >
                <if test="open_id!='' and open_id != null">
                open_id,
                </if>
                    <if test="operatortime!='' and operatortime != null">
                operatortime,
                </if>
                    <if test="operatortype!='' and operatortype != null">
                operatortype,
                </if>
                    <if test="operatorcont!='' and operatorcont != null">
                operatorcont,
                </if>
                    <if test="ip!='' and ip != null">
                ip,
                </if>
            </trim>
            <trim prefix="values(" suffix=")" suffixOverrides="," >
                <if test="open_id!='' and open_id != null">
                #{open_id},
                </if>
                    <if test="operatortime!='' and operatortime != null">
                #{operatortime},
                </if>
                    <if test="operatortype!='' and operatortype != null">
                #{operatortype},
                </if>
                    <if test="operatorcont!='' and operatorcont != null">
                #{operatorcont},
                </if>
                    <if test="ip!='' and ip != null">
                #{ip},
                </if>
            </trim>
        </insert>
    Mybatis 配置文件 useGeneratedKeys 参数只针对 insert 语句生效,默认为 false。
    当设置为 true 时,表示如果插入的表以自增列为主键,则允许 JDBC 支持自动生成主键,并可将自动生成的主键返回。
    <insert id="saveMain" parameterType="java.util.HashMap" keyProperty="id" useGeneratedKeys="true">
            insert into <include refid="tableName"></include>(
                <include refid="Field"></include>
            ) values (
                <include refid="FieldValue"></include>
            )
    </insert>

    --------------Mybatis 拼接like ---

     and date_format(company.create_time,'%Y-%m-%d %H:%i:%s') LIKE CONCAT('%', '${params.create_time}', '%')

    ----------------mybatis 判断参数要加.toString()---

    <if test="params.selectTime =='2'.toString() ">
    原创打造,多多指教
  • 相关阅读:
    Handling Errors and Exceptions
    Advanced Features of Delphi DLLs
    How to put a relative path for a DLL statically loaded?
    Delphi DLL制作和加载 Static, Dynamic, Delayed 以及 Shared-Memory Manager
    The useful App Paths registry key : HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionApp Paths
    DLL Dynamic-Link Library Search Order
    Can a windows dll retrieve its own filename?
    Restrict form resize -- Delphi
    Programmer in Google Code
    How to open a web site with the default web browser in a NEW window
  • 原文地址:https://www.cnblogs.com/iscys/p/9550222.html
Copyright © 2020-2023  润新知