title: JPA Query and Relations
body: <p>I'm developing an HRM application so I'm confused to how manage entities over JPA.</p>
  
  <p>My case resuming in is a set of tables in a multilingual context:
  -employees
  -departments
  -languages
  -departments_languages</p>
  
  <p><a href="https://i.stack.imgur.com/FDIhZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FDIhZ.png" alt="enter image description here"></a></p>
  
  <p>following my database tables:</p>
  
  <p>Employee Entity class:</p>
  
  <pre><code>  @Entity
    @Table(name="employees")
    @NamedQuery(name="Employee.findAll", query="SELECT e FROM Employee e")
    public class Employee implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name="employeed_id", unique=true, nullable=false)
      private int employeedId;
  
      @Column(nullable=false, length=255)
      private String address;
  
      @Temporal(TemporalType.DATE)
      @Column(nullable=false)
      private Date birthday;
  
      ...
  
      //bi-directional many-to-one association to Department
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="department_id", nullable=false)
      private Department department
    }
  </code></pre>
  
  <p>Department Entity class</p>
  
  <pre><code>@Entity
  @Table(name="departments")
  @NamedQuery(name="Department.findAll", query="SELECT d FROM Department d")
  public class Department implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column(name="department_id", unique=true, nullable=false)
      private int departmentId;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name="date_added", nullable=false)
      private Date dateAdded;
  
      @Column(name="location_id", nullable=false)
      private int locationId;
  
      @Column(nullable=false)
      private byte status;
  
      //bi-directional many-to-one association to DepartmentsLanguage
      @OneToMany(mappedBy="department")
      private Set&lt;DepartmentsLanguage&gt; departmentsLanguages;
  
      //bi-directional many-to-one association to Employee
      @OneToMany(mappedBy="department",fetch=FetchType.LAZY)
      private Set&lt;Employee&gt; employees;
  
      ...
  }
  </code></pre>
  
  <p>DepartmentLanguage Entity </p>
  
  <pre><code>        @Entity
          @Table(name="departments_languages")
          @NamedQuery(name="DepartmentsLanguage.findAll", query="SELECT d FROM DepartmentsLanguage d")
          public class DepartmentsLanguage implements Serializable {
              private static final long serialVersionUID = 1L;
  
              @EmbeddedId
              private DepartmentsLanguagePK id;
  
              @Column(length=255)
              private String description;
  
              @Column(length=255)
              private String name;
  
              //bi-directional many-to-one association to Department
              @ManyToOne(fetch=FetchType.LAZY)
              @JoinColumn(name="department_id", nullable=false, insertable=false, updatable=false)
              private Department department;
  
              //bi-directional many-to-one association to Language
              @ManyToOne(fetch=FetchType.LAZY)
              @JoinColumn(name="language_id", nullable=false, insertable=false, updatable=false)
              private Language language;
  
              ...
          }
  </code></pre>
  
  <p>Firtly, I ask you if is a correct way and how can I perform JPA queries as:</p>
  
  <pre><code>SELECT * FROM employees
  INNER JOIN departments_languages using(department_id)
  WHERE employeed_id = 1 and language_id = 1
  </code></pre>
  
  <p>From this query I need Employee informations, with department name (assuming that languageId is 1 )</p>
  
  <p>Performing a query from eclipse JPA console return an Employee object with all relationship, but both all correlated results</p>
  
  <p>Can you show me a sample query for this kind of design please</p>