title: Hibernate Criteria: Left Outer Join with restrictions on both tables
body: <p>I am doing a LEFT OUTER JOIN, but I am only able to apply Restrictions on the first table. Is there a way ti apply on the second table as well?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Criteria criteria = this.crudService
          .initializeCriteria(Applicant.class).setFetchMode("products",
                FetchMode.JOIN);.
  </code></pre>
  
  <p>This works (applicant has an applicantName property):</p>
  
  <pre><code>criteria.add(Restrictions.eq("applicantName", "Markos")
  </code></pre>
  
  <p>Neither of these works (product has a productName property)</p>
  
  <pre><code>criteria.add(Restrictions.eq("productName", "product1")
  </code></pre>
  
  <p>criteria.add(Restrictions.eq("products.productName", "product1") // products: the name of the property
  criteria.add(Restrictions.eq("Product.productName", "product1") // Product: the name of the DB table</p>
  
  <p>And this is the exception I am receiving saying (if I understand correctly) that the productName property does not exist in Applicant:</p>
  
  <pre><code>EJB Exception: ; nested exception is: org.hibernate.QueryException: could not resolve property: products.inventedName of: org.myCompany.applicant.entity.Applicant; nested exception is: org.hibernate.QueryException: could not resolve property: products.inventedName of: org.myCompany.applicant.entity.Applicant
  </code></pre>
  
  <p>I tried to use an alias, but this generated an INNER JOIN, instead of the LEFT OUTER JOIN I want.</p>
  
  <p>How can I apply restrictions on both tables?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Issue is probably the same as this:
  <a href="https://forum.hibernate.org/viewtopic.php?p=2393694" rel="nofollow noreferrer">https://forum.hibernate.org/viewtopic.php?p=2393694</a></p>