title: How to map ID to a different column In Grails?
body: <p>When I have ID in the Domain class it worked fine</p>
  
  <pre><code>class Book {
      int id
      String bookAuthor
  
      static constraints = {
          bookAuthor blank: false, maxSize:30
      }
  
      static mapping = {    
          version false
          id generator: 'sequence',
          params: [sequence:'s_book_seq']
      }
  }
  </code></pre>
  
  <p>But once I tried to map Id to BookId, </p>
  
  <pre><code>class Book {
      int bookId
      String bookAuthor
  
      static constraints = {
          bookAuthor blank: false, maxSize:30         
      }
  
      static mapping = {
          version false
          id generator: 'sequence',
          params: [sequence:'s_book_seq'], column :'bookId'
      }
  }
  </code></pre>
  
  <p>Then Grails will fail to start my App. How to map ID to a different field?
  The <strong><code>error</code></strong> i got is:</p>
  
  <pre><code> Error|
   2014-12-27 00:16:01,293 [http-bio-8080-exec-4] ERROR spi.SqlExceptionHelper  - ORA-00904: "THIS_"."B
      OOK_ID": invalid identifier
      Error |
      2014-12-27 00:16:01,412 [http-bio-8080-exec-4] ERROR errors.GrailsExceptionResolver  - SQLSyntaxErro
      rException occurred when processing request: [GET] /gTunes/book/index
      ORA-00904: "THIS_"."BOOK_ID": invalid identifier
      . Stacktrace follows:
      Message: ORA-00904: "THIS_"."BOOK_ID": invalid identifier
          Line | Method
      -&gt;&gt;  445 | processError         in oracle.jdbc.driver.T4CTTIoer
      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      |    396 | processError         in     ''
      |    879 | processError . . . . in oracle.jdbc.driver.T4C8Oall
      |    450 | receive              in oracle.jdbc.driver.T4CTTIfun
      |    192 | doRPC . . . . . . .  in     ''
      |    531 | doOALL               in oracle.jdbc.driver.T4C8Oall
      |    207 | doOall8 . . . . . .  in oracle.jdbc.driver.T4CPreparedStatement
      |    884 | executeForDescribe   in     ''
      |   1167 | executeMaybeDescribe in oracle.jdbc.driver.OracleStatement
      |   1289 | doExecuteWithTimeout in     ''
      |   3584 | executeInternal . .  in oracle.jdbc.driver.OraclePreparedStatement
      |   3628 | executeQuery         in     ''
      |   1493 | executeQuery . . . . in oracle.jdbc.driver.OraclePreparedStatementWrapper
      |     43 | &lt;init&gt;               in grails.orm.PagedResultList
      |     15 | $tt__index . . . . . in test.myapp.BookController
      |    189 | doFilter             in grails.plugin.cache.web.filter.PageFragmentCachingFilter
      |     63 | doFilter . . . . . . in grails.plugin.cache.web.filter.AbstractFilter
      |   1145 | runWorker            in java.util.concurrent.ThreadPoolExecutor
      |    615 | run . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
      ^    744 | run                  in java.lang.Thread
  </code></pre>
  
  <p>Update:</p>
  
  <p>moise2022's solution worked. I can bring up the list page. However the generated ${bookInstance} in the show page is wrong.</p>
  
  <pre><code>&lt;g:link class="edit" action="edit" resource="${bookInstance}"&gt;&lt;g:message code="default.button.edit.label" default="Edit" /&gt;&lt;/g:link&gt;
  </code></pre>
  
  <p>Instead of </p>
  
  <pre><code>&lt;a href="/gTunes/book/edit/1" class="edit"&gt;Edit&lt;/a&gt;
  </code></pre>
  
  <p>It generated </p>
  
  <pre><code>&lt;a href="/gTunes/book/edit" class="edit"&gt;Edit&lt;/a&gt;
  </code></pre>
  
  <p>So edit navigation broke</p>
  
  <p>Update:</p>
  
  <p>For Delete 
  I tried to change </p>
  
  <pre><code>&lt;g:form url="[resource:bookInstance, action:'delete' ]" method="DELETE"&gt;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;g:form url="[resource:bookInstance, action:'delete', id:'${bookInstance.bookId}' ]" method="DELETE"&gt;
  </code></pre>
  
  <p>That still didn't work. </p>
  
  <pre><code>URI:/gTunes/book/show/1Class:java.lang.IllegalArgumentExceptionMessage:named capturing group is missing trailing '}'
  Around line 527 of grails-app\views\book\show.gsp
  
  
  Around line 527 of AbstractFilter.java
  
  
  Around line 50 of grails-app\views\book\show.gsp
  47:                 &lt;g:link class="edit" action="edit" id="${bookInstance.bookId}" &gt;&lt;g:message code="default.button.edit.label" default="Edit" /&gt;&lt;/g:link&gt;&lt;/td&gt;48:                  &lt;g:actionSubmit class="delete" action="delete" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /&gt;49:                &lt;/fieldset&gt;50:          &lt;/g:form&gt;51:        &lt;/div&gt;52:   &lt;/body&gt;53:&lt;/html&gt;
  </code></pre>