title: How to map mysql table to Grails domain class?
body: <p>I have mysql table named <code>anto2</code>. Which has only one column <code>name</code> of <code>varchar 100</code>. I tried to map this table in grails domain class : </p>
  
  <pre><code>class Anto {
  
      String grailsName
  
      static constraints = {
      }
  
      static mapping = {
          table 'anto2'
          grailsName column: 'name'
      }
  }
  </code></pre>
  
  <p>After I did <code>run-app</code> I can see my table have been added with two more columns : </p>
  
  <pre><code>+---------+--------------+------+-----+---------+-------+
  | Field   | Type         | Null | Key | Default | Extra |
  +---------+--------------+------+-----+---------+-------+
  | name    | varchar(100) | YES  |     | NULL    |       |
  | id      | bigint(20)   | NO   |     | NULL    |       |
  | version | bigint(20)   | NO   |     | NULL    |       |
  +---------+--------------+------+-----+---------+-------+
  </code></pre>
  
  <p>I generated static view and controller for this Domain class and when I tried to save it , I get an error in my <code>save()</code> method (which is generated using <code>generate-all</code> command). The error is as follows :</p>
  
  <pre><code>2012-07-09 23:05:26,391 [http-bio-8080-exec-2] ERROR errors.GrailsExceptionResolver  - SQLException occurred when processing request: [POST] /mysql/anto/save - parameters:
  create: Create
  Field 'id' doesn't have a default value. Stacktrace follows:
  Message: Field 'id' doesn't have a default value
      Line | Method
  -&gt;&gt; 1073 | createSQLException in com.mysql.jdbc.SQLError
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   3597 | checkErrorPacket   in com.mysql.jdbc.MysqlIO
  |   3529 | checkErrorPacket . in     ''
  |   1990 | sendCommand        in     ''
  |   2151 | sqlQueryDirect . . in     ''
  |   2625 | execSQL            in com.mysql.jdbc.ConnectionImpl
  |   2119 | executeInternal .  in com.mysql.jdbc.PreparedStatement
  |   2415 | executeUpdate      in     ''
  |   2333 | executeUpdate . .  in     ''
  |   2318 | executeUpdate      in     ''
  |    105 | executeUpdate . .  in org.apache.commons.dbcp.DelegatingPreparedStatement
  |     25 | save               in mnm.AntoController
  |   1110 | runWorker . . . .  in java.util.concurrent.ThreadPoolExecutor
  |    603 | run                in java.util.concurrent.ThreadPoolExecutor$Worker
  ^    722 | run . . . . . . .  in java.lang.Thread
  </code></pre>
  
  <p>Why does this happen? Where I went wrong?</p>