title: HIbernate overwrite data when persist/save entity
body: <p>I am new in Hibernate.when i save particular entity then it rewrite data from existing one.</p>
  
  <p>I have used ID as auto generated as below:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy=GenerationType.AUTO)
  @Column(name="id")
  private int id;
  </code></pre>
  
  <p>Here i save Entity as below:</p>
  
  <pre><code>class StudDAO() {
  
  public static void main(String[] args){
       StudDAO obj = new StudDAO();
       Stud stud = new Stud();
       stud.setName("Test");
       stud.setCity("Mumbai");
       obj.createStud(stud);
  }
  
  public void createStud(Stud stud) {
    try {
  
      Session session = HibernateSessionFactory.getSessionFactory().openSession();
      Transaction transaction = session.beginTransaction();
      session.save(stud);
      transaction.commit();
  
      } catch (Exception e) {
        // TODO: handle exception
         e.printStackTrace();
         transaction.rollback();
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>if i will change entity value next time then it should generate next id rather than starting form 1st id.</p>
  
  <p>any time result would be same like </p>
  
  <pre><code>mysql&gt; select * from stud;
  
  +----+--------+------+
  | id | city   | name |
  +----+--------+------+
  |  1 | Mumbai | Test |
  +----+--------+------+
  </code></pre>
  
  <p>1 row in set (0.00 sec)</p>
  
  <p>what i want is in result like below:</p>
  
  <pre><code>mysql&gt; select * from stud;
  +----+--------+------+
  | id | city   | name |
  +----+--------+------+
  |  1 | Mumbai | Test |
  |  2 | Mumbai | Test |
  +----+--------+------+
  2 rows in set (0.00 sec)
  </code></pre>
  
  <p>Please help me for same..</p>