title: Hibernate Iterator retrieving same data
body: <p>I have a form that is connected to the database via hibernate. With this form, the user can go in and fill out fields such as names, address, and email information, etc. After they are all done filling out information they would submit the form. After submit, all the information would be display on a data table on the same page. </p>
  
  <p>I am using session to interact with the database. However, the data that is being populated from database doesn't seem to be right.</p>
  
  <pre><code>public void somefunction() {
  
      //The sessionfactory is being configured in another class
      Session s = sessionFactory.openSession(); 
      Transaction tx= null;
  
      try {
          tx= s.beginTransaction();
  
          List userInformation = s.createQuery("FROM database1 WHERE PKEY ='"+somevalue+"'").list();
  
          for(Iterator iterator = userInformation.iterator; iterator.hasNext();){
  
              //database1 is an entity bean
              database1 x = (database1) iterator.next();
  
              System.out.print(x.getName());
          }
          tx.commit();
      }
      catch(Exception) {......}
      finally {.....}
  }
  </code></pre>
  
  <p>After the user submit the first "user" with their information, everything shows up in the datatable fine. However, when they enter a second "user" the row displayed on the datatable is the same information as the first user, even though the data is different. I think the code looks correct, so i am not sure what could be wrong with this.</p>