//sqlmap java
<insert id="insertTask" parameterClass="task">
<selectKey resultClass="java.lang.String" keyProperty="mainid">
select NEWID() as mainid
</selectKey>
INSERT INTO
Course_Task
(MainID,Task_CourseID,Task_Content,Task_TurnedDate,Task_CreateDate,
Task_isRead,Task_RealName,Task_saveurl,Task_filetype,Task_filesize,Task_uploaduserid,Course_ContentID)
VALUES
(#mainid#,#courseID#,#content#,#turnedDate#,getDate(),
#isRead#,#realName#,#saveurl#,#filetype#,#filesize#,#uploaduserid#,#coursecontentID#)
</insert>sql
//daothis
public Object save(Object obj) {
// TODO Auto-generated method stub
return (String)this.getSqlMapClientTemplate().insert("insertTask", obj);
}url
//strusts2 actionget
String mainid=(String)taskService.save(t); //獲取新插入的表的主鍵io