XML配置文件:
- <!-- 添加 -->
- <insert id="add" parameterClass="java.util.HashMap" >
- <![CDATA[
- INSERT INTO TS_AREA(TITLE,PID) VALUES(#title#,#pid#)
- ]]>
- <selectKey resultClass="int" keyProperty="area_id" >
- SELECT @@IDENTITY AS area_id
- </selectKey>
- </insert>
调用代码:
- /*
- *增加地区,插入成功,返回插入记录的主键值,插入失败,返回0
- *ts_area
- */
- public int add(Map map) {
- int result = 0;
- try {
- result = Integer.parseInt(sqlMapClient.insert("area.add", map)+"");
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return result;
- }
转载自http://huangqiqing123.iteye.com/blog/1555703