title: An attempt was made to modify the identity column ' ID'
body: <p>I have problem with my project. My apache derby generate id, in table it works. But in app it doesnt work. In derby I set id autoincrement (start with 1, increment by 1), but i get this error:</p>
  
  <pre><code>&gt; Caused by: ERROR 42Z23 : An attempt was made to modify the identity
  &gt; column ' ID'
  </code></pre>
  
  <p>.</p>
  
  <p>My entity:</p>
  
  <pre><code>package com.springapp.mvc.models;
  
  import javax.persistence.*;
  
  @Entity
  @Table(name = "USERS", schema = "KK", catalog = "")
  public class UsersEntity {
      private int id;
      private String name;
      private String password;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "ID")
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      @Basic
      @Column(name = "NAME")
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      @Basic
      @Column(name = "PASSWORD")
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
  
          UsersEntity that = (UsersEntity) o;
  
          if (id != that.id) return false;
          if (name != null ? !name.equals(that.name) : that.name != null) return false;
          if (password != null ? !password.equals(that.password) : that.password != null) return false;
  
          return true;
      }
  
      @Override
      public int hashCode() {
          int result = id;
          result = 31 * result + (name != null ? name.hashCode() : 0);
          result = 31 * result + (password != null ? password.hashCode() : 0);
          return result;
      }
  }
  </code></pre>
  
  <p>hibernate xml:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD//EN"
          "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;property name="connection.url"&gt;jdbc:derby://localhost:1527/MyDB&lt;/property&gt;
          &lt;property name="connection.driver_class"&gt;org.apache.derby.jdbc.ClientDriver&lt;/property&gt;
  
          &lt;!-- SQL dialect --&gt;
          &lt;property name="dialect"&gt;org.hibernate.dialect.DerbyDialect&lt;/property&gt;
          &lt;!-- &lt;property name="hbm2ddl.auto"&gt;update&lt;/property&gt;
  Enable Hibernate's automatic session context management --&gt;
          &lt;property name="current_session_context_class"&gt;thread&lt;/property&gt;
          &lt;mapping resource="mapping.xml"/&gt;
          &lt;mapping class="com.springapp.mvc.models.AccountEntity"/&gt;
          &lt;mapping class="com.springapp.mvc.models.BookEntity"/&gt;
          &lt;mapping class="com.springapp.mvc.models.UsersEntity"/&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>mapping.xml</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC
      "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
      "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
  
      &lt;class name="com.springapp.mvc.models.AccountEntity" table="ACCOUNT" schema="KK"&gt;
          &lt;id name="id" column="ID"/&gt;
          &lt;property name="name" column="NAME"/&gt;
          &lt;property name="accountprefix" column="ACCOUNTPREFIX"/&gt;
          &lt;property name="accountnumber" column="ACCOUNTNUMBER"/&gt;
          &lt;property name="bankcode" column="BANKCODE"/&gt;
          &lt;property name="userid" column="USERID"/&gt;
      &lt;/class&gt;
      &lt;class name="com.springapp.mvc.models.BookEntity" table="BOOK" schema="KK"&gt;
          &lt;id name="id" column="ID"/&gt;
          &lt;property name="title" column="TITLE"/&gt;
          &lt;property name="description" column="DESCRIPTION"/&gt;
          &lt;property name="userid" column="USERID"/&gt;
      &lt;/class&gt;
      &lt;class name="com.springapp.mvc.models.UsersEntity" table="USERS" schema="KK"&gt;
          &lt;id name="id" column="ID"/&gt;
          &lt;property name="name" column="NAME"/&gt;
          &lt;property name="password" column="PASSWORD"/&gt;
      &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Thanks</p>