title: Auto Increment with hibernate
body: <p>I need to set a auto increment for a field in my table.</p>
  
  <p>This is my Entity class:</p>
  
  <pre><code>@Entity
  @Table(name = "UserLogin")
  public class User implements Serializable {
  
  private int id;
  private String username;
  private String password;
  private String fname;
  private String lname;
  private String emailId;
  private boolean loginperson;
  private String manager;
  
  @Id
  @GeneratedValue
  @Column(name = "empolyeeId")
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  @Column(name = "username", nullable = false)
  public String getUsername() {
      return username;
  }
  
  public void setUsername(String username) {
      this.username = username;
  }
  
  @Column(name = "password", nullable = false)
  public String getPassword() {
      return password;
  }
  
  public void setPassword(String password) {
      this.password = password;
  }
  
  @Column(name = "firstName", nullable = false)
  public String getFname() {
      return fname;
  }
  
  public void setFname(String fname) {
      this.fname = fname;
  }
  
  @Column(name = "lastName", nullable = false)
  public String getLname() {
      return lname;
  }
  
  public void setLname(String lname) {
      this.lname = lname;
  }
  
  @Column(name = "emailId", nullable = false)
  public void setEmailId(String emailId) {
      this.emailId = emailId;
  }
  
  public void setManager(String manager) {
      this.manager = manager;
  }
  
  @Column(name = "loginperson", nullable = false)
  public boolean isLoginperson() {
      return loginperson;
  }
  
  public void setLoginperson(boolean loginperson) {
      this.loginperson = loginperson;
  }
  
  @Column(name = "manager", nullable = false)
  public String getManager() {
      return manager;
  }
  
  public String getEmailId() {
      return emailId;
  }
  </code></pre>
  
  <p>Here I am not able have set Generated value for the id field.But it is not creating the the auto increment for the id field.</p>
  
  <p>I have tried with  </p>
  
  <pre><code>@GeneratedValue(strategy=GenerationType.AUTO)
  </code></pre>
  
  <p>and  </p>
  
  <pre><code>@GeneratedValue(strategy=GenerationType.IDENTITY)
  </code></pre>
  
  <p>But the table is not getting created in mysql database.</p>
  
  <p>I am getting the following log.</p>
  
  <pre><code>    ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - Unsuccessful: create table UserLogin (empolyeeId integer generated by default as identity (start with 1), emailId varchar(255), firstName varchar(255) not null, lastName varchar(255) not null, loginperson bit not null, manager varchar(255) not null, password varchar(255) not null, username varchar(255) not null, primary key (empolyeeId))
      ERROR: org.hibernate.tool.hbm2ddl.SchemaExport - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'generated by default as identity (start with 1), emailId varchar(255), firstName' at line 1
  </code></pre>