title: Hibernate returns duplicate values if result size is greater than 1
body: <p>I have a simple table in PostgreSQL called "transaction_response". In this table, there are only two columns: transaction_id and response_id.</p>
  
  <p>The data I have in there are two rows. Both with the same transaction_id, but different response_id values.</p>
  
  <p>I created the following Java class to hold this data:</p>
  
  <pre><code>public class TransactionResponseDAO implements java.io.Serializable {
      private Integer transactionId;
      private Integer responseId;
  
      public Integer getTransactionId() {
          return transactionId;
      }
  
      public void setTransactionId(Integer transactionId) {
          this.transactionId = transactionId;
      }
  
      public Integer getResponseId() {
          return responseId;
      }
  
      public void setResponseId(Integer responseId) {
          this.responseId = responseId;
      }
  
      public String toString() {
          return "Transaction Id: " + transactionId + "\nResponse Id: " + responseId;
      }
  }
  </code></pre>
  
  <p>I then created the Hibernate config file called "TransactionResponse.hbm.xml":</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt;
  &lt;hibernate-mapping&gt;
      &lt;class name="com.data.TransactionResponseDAO" table="transaction_response"&gt;
          &lt;id name="transactionId" column="transaction_id" type="java.lang.Integer"&gt;
              &lt;generator class="increment"/&gt;
          &lt;/id&gt;
  
          &lt;property name="responseId" type="java.lang.Integer"&gt;
              &lt;column name="responses_id" /&gt;
          &lt;/property&gt;
  
      &lt;/class&gt;
  
      &lt;query name="findTransactionResponseByTransactionId"&gt;
          &lt;![CDATA[from com.data.TransactionResponseDAO where transaction_id = :transactionId]]&gt;
      &lt;/query&gt;
  
      &lt;query name="findTransactionResponseByBothIds"&gt;
          &lt;![CDATA[from com.data.TransactionResponseDAO where transaction_id = :transactionId 
                   and responses_id = :responseId]]&gt;
      &lt;/query&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>In a Java class I am testing this with, I have the following code:</p>
  
  <pre><code>Query q = null;
          SessionFactory sFactory = new Configuration().configure("/conf/hibernate.cfg.xml").buildSessionFactory();
          Session session = null;
  
          try {
              session = sFactory.openSession();
              q = session.getNamedQuery("findTransactionResponseByTransactionId");
              q.setInteger("transactionId", transactionId);
          }catch (Exception e) {
              System.err.println("Error running getStatusTab");
              e.printStackTrace();
  
              session.close();
              sFactory.close();
          }
  
          ArrayList&lt;TransactionResponseDAO&gt; results = (ArrayList&lt;TransactionResponseDAO&gt;) q.list();
  
          session.close();
          sFactory.close();
  
          System.out.println("&gt;&gt;&gt; Size: " + results.size());
  
          for (TransactionResponseDAO tr : results) {
              System.out.println(tr);
              System.out.println();
          }
  </code></pre>
  
  <p>When I run this code, it returns two rows back, as it should. However, when printing out the values... the response_id is the same for both rows. So it doesn't seem to be pulling in the second response_id value for some reason.</p>
  
  <p>Any reason why this is? As always, I appreciate the help!</p>