title: JPA/Hibernate select query returning duplicate records
body: <p>I have a table ,say, Instrument with ID,State, and User_ID as columns.</p>
  
  <p>So I have this JPA query to return all the instrument records with a matching
  User_ID.</p>
  
  <pre><code>   query = manager.createQuery("SELECT instrument from Instrument instrument
               where instrument.User_ID=:User_ID",Instrument.class);
     query.setParameter("User_ID", User_ID);
  
     List&lt;Instrument&gt; instruments=  query.getResultList();
  
     for(Instrument instrument:instruments){
              System.out.println("Instrument ID  "+instrument.getID());
                // using sysout as it is not prod code yet
          }
  </code></pre>
  
  <p>It is returning only the first record repeated as many times as there are matching records.</p>
  
  <pre><code>11:13:01,703 INFO  [stdout] (http-/127.0.0.1:8080-1) Instrument ID   1
  11:13:01,704 INFO  [stdout] (http-/127.0.0.1:8080-1) Instrument ID   1
  11:13:01,704 INFO  [stdout] (http-/127.0.0.1:8080-1) Instrument ID   1
  </code></pre>
  
  <p>I have three records in Db with instrument IDs 1,2, and 3</p>
  
  <p>I enabled show sql query on hibernate and the query runs fine on the Database directly
  and returns distinct records.</p>
  
  <p>Hibernate Query:</p>
  
  <pre><code>    select instrumentjdo0_.User_ID as member_U1_0_, instrumentjdo0_.ID as ID2_0_, 
  instrumentjdo0_.state as state4_0_ from instrument instrumentjdo0_ where instrumentjdo0_.User_ID=?
  </code></pre>
  
  <p>Instrument Entity</p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.Table;
  
  
  
  
  @Entity
  @Table(name = "instrument")
  public class Instrument{
  
      @Id
      @Column(name="User_ID", length=9, unique=true, nullable=false)
      String user_ID;
  
      @Column(name="ID",nullable=false)
      String ID;
  
  
      @Column(name="state",nullable=false)
      String state;
  
      public String getID() {
          return ID;
      }
  
      public void setID(String ID) {
          this.ID = ID;
      }
  
      public String getUserID() {
          return user_ID;
      }
  
      public void setUserID(String userID) {
          this.user_ID = userID;
      }
  
  
      public String getState() {
          return state;
      }
  
      public void setState(String state) {
          this.state = state;
      }
  }
  </code></pre>
  
  <p>Not sure what I am missing.</p>