iBatis中的insert如何返回主键ibatis insert返回


Xml代码  

   

   

   

   

   

   

   


   

   

   

   

   

   

   


   

   

   

   SELECT SCOPE_IDENTITY() AS ID ]]>    

   

   


   

   

   

   

   

   

   


或推荐方式

SELECT LAST_INSERT_ID() AS id

insert into category (name_zh, parent_id,

show_order, delete_status, description

)

values (#{nameZh,jdbcType=VARCHAR},

#{parentId,jdbcType=SMALLINT},

#{showOrder,jdbcType=SMALLINT},

#{deleteStatus,jdbcType=BIT},

#{description,jdbcType=VARCHAR}

)



 

 

 

 

 

 

 


 

 

 

 

 

 

 


 

 

 

   SELECT SCOPE_IDENTITY() AS ID ]]>