title: Hibernate Exception: identifier of an instance of x was altered
body: <p>This is my test code:</p>
  
  <pre><code>        Employee emp = new Employee();
  
          emp.setUsername("test");
          emp.setPassword("test");
          sf = new Configuration().configure().buildSessionFactory();
          log.debug("SessionFactory created");
          session = sf.openSession();
          Transaction tx = session.getTransaction();
          tx.begin();
  
          log.debug("Saving Employee");
          System.out.println(emp);
          session.save(emp);
          session.flush();
  
          if(!tx.wasCommitted())
          {
              tx.commit();
              log.debug("Employee saved");
          }
  </code></pre>
  
  <p>This is my Employee Class</p>
  
  <pre><code>@Entity
  @Table(name = "EMPLOYEES")
  public class Employee 
  {
  @Id
  @GenericGenerator(name="emp_id_sq", strategy="generator.EmployeeIdGenerator")
  @GeneratedValue(generator="emp_id_sq")
  @Column(name = "EMP_ID", unique = true, nullable = false)
  private long id;
  
  @Column(name = "USERNAME", unique = true, nullable = false)
  private String username;
  
  @Column(name = "PASSWORD", nullable = false)
  private String password;
  
  @OneToMany(mappedBy = "employee")
  private Collection&lt;Timecard&gt; timecards;
  </code></pre>
  
  <p>Error I receive: org.hibernate.HibernateException: identifier of an instance of models.Employee was altered from 24 to 24</p>
  
  <p>I have no idea why I'm getting the error, but it happens when I try to commit the save.</p>