Add keyProperty attributes and attribute userGeneratedKeys insert the tag in the mapping files
<! - and returns the user to add primary key -> <!-- keyProperty: The primary key for the entity based on attributes in userGeneratedKeys: indicates whether to generate the primary key --> <insert id="insert" keyProperty="uid" useGeneratedKeys="true"> insert into users (name,age) value(#{uname},#{uage}); </insert> |