title: Hibernate CriteriaBuilder with two parameters
body: <p>I am using Java8 with Hibernate 5.2.1 and JPA2 with MySQL.</p>
  
  <p>I have the following query that works perfectly:</p>
  
  <pre><code>    final EntityManagerFactory entityManagerFactory = entityManager.getEntityManagerFactory();
      final CriteriaBuilder criteriaBuilder = entityManagerFactory.getCriteriaBuilder();
      CriteriaQuery&lt;Rating&gt; criteria = criteriaBuilder.createQuery(Rating.class);
      Root&lt;Rating&gt; root = criteria.from(Rating.class);
      ParameterExpression&lt;Job&gt; paramJob = criteriaBuilder.parameter(Job.class);
  
      criteria.select(root).where(criteriaBuilder.equal(root.get("job"), paramJob));
  </code></pre>
  
  <p>As you can see, the query has one parameter <code>paramJob</code>. I would like to add a second parameter:</p>
  
  <pre><code>    ParameterExpression&lt;Person&gt; paramPerson = criteriaBuilder.parameter(Person.class);
  </code></pre>
  
  <p><strong>Question</strong></p>
  
  <p>How do I modify the following line to accommodate the second parameter?</p>
  
  <pre><code>criteria.select(root).where(criteriaBuilder.equal(root.get("job"), paramJob));
  </code></pre>
  
  <p>Can I just add a second line:</p>
  
  <pre><code>criteria.select(root).where(criteriaBuilder.equal(root.get("person"), paramPerson));
  </code></pre>
  
  <p>Thanks</p>