title: Grails one-to-one mapping that shares an ID
body: <p>I have the following domain classes in Grails <strong>2.3.11</strong>. They are mapping to legacy database tables that can't be changed. Both classes share an id called <code>pidm</code>:</p>
  
  <pre><code>class Person {
      Long pidm
      String firstName
      String middleName
      Bio bio
  
      static mapping = {
          id name: 'pidm', generator: 'assigned'
          bio column: 'pidm'
      }
  }
  
  class Bio {
      Long pidm
      String ssn
      String gender
      Date birthDate
  
      static mapping = {
          id name: 'pidm', generator: 'assigned'
      }
  }
  </code></pre>
  
  <p>There is no separate <code>person_id</code> column in the <code>Bio</code> table or anything like that. There should be a one-to-one mapping via <code>pidm</code>.</p>
  
  <p>Currently the only way I can get this to work is to add <code>updateable: false, insertable: false</code> to <code>bio</code> in the <code>mapping</code> block. What if I want to update and/or insert a Bio instance? Is there a better way for me to do this and share the <code>pidm</code> column as the id for the Person class <em>AND</em> as a reference to Bio? </p>