zoukankan      html  css  js  c++  java
  • mysql +ibatis

    1.返回插入ID

    a.xml

    <insert id="insert" parameterClass="klcQuestion">
    insert into KLC_QUESTION
    (QUESTION_TITLE,QUESTION_DESC,STATUS,MODIFIER,CREATOR,GMT_CREATE,GMT_MODIFY,ANONYMOUS)
    values (#questionTitle#,#questionDesc#,1,#modifier#,#creator#,now(),now(),#anonymous#)
    <selectKey resultClass="int" type="post" keyProperty="id" >
    select LAST_INSERT_ID() as value
    </selectKey>
    </insert>

    b. java 类操作

    public int insert(KlcQuestion klcQuestion) {
    return (Integer) this.getSqlMapClientTemplate().insert("KlcQuestion.insert", klcQuestion);
    }

    2. ibatis result select 使用

    <resultMap class="dataApiDetail" id="dataApiDetailMap">
    <result property="id" column="id"/>
    <result property="name" column="name"/>
    <result property="description" column="description"/>
    <result property="dataOwner" column="dataOwner"/>
    <result property="dataType" column="dataType"/>
    <result property="dataId" column="dataId"/>
    <result property="dpList" select="dataApiDetailProperty.getDetailTagByDId" column="id" />
    <result property="tagList" select="dataApiDetailTag.getDetailTagByDId" column="id"/>
    </resultMap>

    3.ibatis iterate 使用

    <select id="getDataOwnerByCatId" resultClass="string" parameterClass="java.util.Map">
    SELECT
    DISTINCT(DATA_OWNER)
    FROM DATA_API_DETAIL
    WHERE STATUS = 1
    <isNotEmpty prepend="AND" property="idList">
    <iterate prepend="CATEGORY_ID IN" property="idList" conjunction="," open="(" close=")" >
    #idList[]#
    </iterate>
    </isNotEmpty>
    </select>

  • 相关阅读:
    Hello World
    函数
    js基础
    html
    npm
    数据库
    前端了解的简要php
    模块
    scrapy爬虫
    php升级代码检查
  • 原文地址:https://www.cnblogs.com/Snowflake/p/3620915.html
Copyright © 2011-2022 走看看