title: How to make string primary key hibernate. @GeneratedValue strategies
body: <p>My goal is to create an entity Device that has a unique field IMEI and I would like to use it as a primary key, and specify it at device registration time (manually specified, while creating the entity). 
  I use Spring roo tool for development and hibernate as ORM.</p>
  
  <p>When I specify this in Entity declaration:</p>
  
  <pre><code>@RooJavaBean
  @RooToString
  @RooJpaActiveRecord(identifierField = "IMEI", identifierType = String.class)
  public class Device {...}
  </code></pre>
  
  <p>I get this generated:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "IMEI")
  private String Device.IMEI;
  </code></pre>
  
  <p>While deploying project to server with mysql db i get this error:</p>
  
  <pre><code>2013-03-17 20:03:23,136 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - HHH000389: Unsuccessful: create table device (imei varchar(255) not null auto_increment, model varchar(255), name varchar(255) not null, version integer, primary key (imei))
  2013-03-17 20:03:23,136 [main] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - Incorrect column specifier for column 'imei'
  </code></pre>
  
  <p>Then I override roo generated field with </p>
  
  <pre><code>@Id
  @GeneratedValue(generator = "org.hibernate.id.Assigned")
  @Column(name = "the_code")
  private String code;
  </code></pre>
  
  <p>(I've found this in <a href="http://forum.springsource.org/archive/index.php/t-114225.html?s=daed6da207ea08e4584a88621b35c77e" rel="nofollow noreferrer">here</a>)</p>
  
  <p>But still get error. Then I've changed code simply to this:</p>
  
  <pre><code> @Id
  private String IMEI;
  </code></pre>
  
  <p>and then it works fine and asks me to specify imei field before saving entity.</p>
  
  <p>My questions are:</p>
  
  <p>Is it correct to use my custom field as id?</p>
  
  <p>Is it ok to by String?</p>
  
  <p>is it ok that it is not generated with hibernate but taken from the device imei?</p>
  
  <p>What is org.hibernate.id.Assigned?</p>
  
  <p>Why roo generated code for     @RooJpaActiveRecord(identifierField = "IMEI", identifierType = String.class) does not work?</p>
  
  <p>Is it posible to create String auto generated primary key?</p>
  
  <p>What is default GeneratedValue strategy value (my last case)?</p>
  
  <p>I've read<a href="http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entity-mapping-identifier" rel="nofollow noreferrer">official doc</a> but didn't understand all, please refer me to article where i can read about all this.</p>
  
  <p>Thanks, sorry for long question.</p>