title: how to query the join table using hibernate?
body: <p>I have created three tables in Oracle SQL Developer namely </p>
  
  <p><code>1.Test_Employee2</code><br>
  <code>2.Test_Project2</code><br>
  <code>3.Employee_Project2</code>.<br>
  The table <code>Employee_Project2</code> is the join table as the relation between <code>Test_Project2</code> and <code>Employee_Project2</code> is <code>Many-To-Many</code>.<br>
  In hibernate I created to two hibernate classes <code>TestEmployee</code> and <code>TestProject</code> for <code>Test_Project2</code> and <code>Employee_Project2</code> tables respectively,<br>
  and the table <code>Employee_Project2</code> was defined in <code>TestProject</code> hibernate class as follows:</p>
  
  <pre><code>@ManyToMany(cascade = CascadeType.ALL)
  @JoinTable(name = "Employee_Project2", joinColumns = @JoinColumn(name = "proj_id"), inverseJoinColumns = @JoinColumn(name = "emp_id"))
  private Set&lt;TestEmployee&gt; employeesList;
  </code></pre>
  
  <p>I populated the tables <code>Test_Project2</code> and <code>Employee_Project2</code> with some records, and the join table <code>Employee_Project2</code> automatically got populated with some records.
  now the problem I am facing currently is, I want to use a simple select statement on the join table <code>Employee_Project2</code> using hiberante as follows:</p>
  
  <pre><code>String hql = "FROM Employee_Project2";
      Query query = session.createQuery(hql);
      List results = query.list();
  
      for (Object row : results) {
          //what to do here
      }
  </code></pre>
  
  <p>how can I do that despite the join table 'Employee_Project2' is not a hibernate class.?</p>
  
  <p><strong>update</strong>:</p>
  
  <p>I would like to retrieve all the records in the hibernate table "TestProject", so i wrote the following code</p>
  
  <pre><code>String hql = "FROM TestProject";
  Query query = session.createQuery(hql);
  List results = query.list();
  System.out.println("results.get(0)" + results.get(0).toString());
  </code></pre>
  
  <p>now the problem is, at run time i receive something like the following</p>
  
  <pre><code>results.get(0)msc.hibernate.persistence.TestProject@12ec9534
  </code></pre>
  
  <p>how can i get the values contained in the each row??</p>