SQL Server command: Select NewId (), you can get the native UUID value of the SQL Server database, so we can write this instruction to MyBatis's primary key generation policy configuration Selectkey.
As follows:
In the Mapper.xml type mapping configuration file
<insert id= "Insert" parametertype= "Com.hqdl.xiaoyi.bean.SpUser" > <selectkey keyproperty= "id" resulttype= " String "order=" before "> select NewId () </selectKey> INSERT into sp_user_list (ID, name, fu Ll_name, password, category, User_type, company_id, depart_id, code, Locked, Wrong_pwd_count, Last_login _time, Lock_reason, create_user_id, Create_person_name, create_time, deleted) VALUES (#{id,jdbctype=varchar }, #{name,jdbctype=varchar}, #{fullname,jdbctype=varchar}, #{password,jdbctype=varchar}, #{category,jdbcType= VARCHAR}, #{usertype,jdbctype=varchar}, #{companyid,jdbctype=varchar}, #{departid,jdbctype=varchar}, #{code, Jdbctype=varchar}, #{locked,jdbctype=char}, #{wrongpwdcount,jdbctype=integer}, #{lastlogintime,jdbctype=varchar}, #{lockreason,jdbctype=varchar}, #{createuserid,jdbctype=varchar}, #{createpersonname,jdbctype=varchar}, #{creat Etime,jdbctype=varchar}, #{deleted,jdbctype=chaR}) </insert>
Get Insert Results
MyBatis generating a policy for the primary key ID for SQL Server