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>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。