title: How do I return my auto-generated ID in my MyBatis object?
body: <p>I’m using <code>MySQL 5.5.46</code> with <code>MyBatis 3.3</code> and <code>Spring 4.2</code>.  I have a table with a primary key column that is of type <code>VARCHAR(32)</code>.  In my mapping file, I have this statement.  Notice that I use MySql’s <code>uuid()</code> to auto-generate an ID.  How do I then take this ID and populate it in the returned object?  I’m trying <code>LAST_INSERT_ID()</code> but that isn’t doing it …</p>
  
  <pre><code>&lt;insert id="insertMyObject" parameterType="org.mainco.myproject.domain.MyObject" keyProperty="id"  keyColumn="id"&gt;
      insert into cb_myproject_sync_entity_link(id, links_self, links_schools, links_teachers, links_students, links_sections, links_grade_levels, links_contacts)
      values(replace(uuid(), '-', ''),#{linksSelf}, #{linksSchools}, #{linksTeachers}, #{linksStudents}, #{linksSections}, #{linksGradeLevels}, #{linksContacts})     
     &lt;selectKey keyProperty="id" resultType="String" order="AFTER"&gt;SELECT LAST_INSERT_ID();&lt;/selectKey&gt;
  &lt;/insert&gt;
  </code></pre>