title: How to preform the JOIN FETCH query to get the correct result?
body: <p>Ok guys, I got something like this:</p>
  
  <p>A student with ID, Name and Last name...</p>
  
  <p>Now I created a new java class called <code>ACCOUNTS</code> with Id, Name and Value</p>
  
  <p>There is also this:</p>
  
  <pre><code>@OneToMany(cascade = { CascadeType.ALL})
  private Set&lt;BankAccout&gt; accounts;
  
  public Student() {
      accounts= new HashSet&lt;BankAccout&gt;();
  }
  
      public Set&lt;BankAccout&gt; getAccounts() {
      return accounts;
  }
  
  public void setAccounts(Set&lt;BankAccout&gt; accounts) {
      this.accounts= accounts;
  }
  </code></pre>
  
  <p>Now, I have my site, on the site there is a table with the data of all students... they are all unique</p>
  
  <p>Then I had to write a new class, and I have to add a listBox to my site, that shows the selected students accounts...</p>
  
  <p>My old query for calling the student looked like this:</p>
  
  <pre><code>@GET
  @Path("/getAll")
  @Produces(MediaType.APPLICATION_JSON)
  public List&lt;Student&gt; getAll() {
      return em.createQuery("from Student s").getResultList();
  }
  </code></pre>
  
  <p>and the controller for that looks like this:</p>
  
  <pre><code>$http.get('http://localhost:8080/CreditCardWEB/rest/cc/getAll').success(
          function(data) {
              $scope.result = data;
          });
  </code></pre>
  
  <p>And it all worked...in the table there were no problems....but i had to change the query to be able to bind the data from the accounts to the table....and now the query looks like this...</p>
  
  <pre><code>return em.createQuery("from Student s inner join fetch s.accounts").getResultList();
  </code></pre>
  
  <p>and now, the table SHOULD show me the same data as before...that is, the all students that are all unique....but it shows me only those students that have at least one account....and not only that, but the same student is shown not once, but more times (the number he has accounts) in the table...</p>
  
  <p>Any suggestions?</p>