风扬  

 

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>

posted on 2014-03-24 15:04  风扬扬  阅读(315)  评论(0编辑  收藏  举报