title: hibernate id generator AUTO_INCREMENT at h2 and MySQL in a cluster
body: <p>For testing I'm using the <strong>H2 database</strong>.</p>
  
  <p>For production it's <strong>MySQL</strong>.</p>
  
  <p>I understrand that both support <code>AUTO_INCREMENT</code> (<a href="http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html" rel="nofollow">mysql</a> / <a href="http://www.h2database.com/html/grammar.html#column_definition" rel="nofollow">h2</a>), but it seems like Hibernate doesn't work this way.</p>
  
  <p><code>identity</code> is supported for MySQL. Fine.<br/>
  What about H2? Should I write my own generator or...? (using the <code>org.hibernate.id.IdentifierGenerator</code> interface as the doc <a href="http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html_single/#d5e2502" rel="nofollow">says</a>).</p>
  
  <p>I must have a nice clean &amp; quick way to get an ID (of type <code>long</code> by the way) from the database itself because <strong>the application is in a cluster</strong> (i.e several servers <code>INSERT</code> into the database at once)... that's why <code>increment</code> is definitely not for me.</p>
  
  <p>Thanks!</p>