title: Hibernate criteria for OneToMany/ManyToOne relationship
body: <p>I have a OneToMany/ManyToOne relationship between two objects like:</p>
  
  <pre><code>public class Company {
      private Long compid;
      private String companyName;
  
      @OneToMany(mappedBy = "company", cascade = CascadeType.ALL)
      @LazyCollection(LazyCollectionOption.FALSE)
      private List&lt;Employee&gt; employees;
  }
  
  public class Employee {
      private Long empid;
      private String fstName;
      private String lstName;
      private String sal;
  
      @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      @NotFound(action = NotFoundAction.IGNORE)
      @JoinColumn(name = "compid", nullable = true)
      private Company company;
  }
  </code></pre>
  
  <p>I want to get the employees who have <code>company.companyName like xxxx%</code>. I tried something like:</p>
  
  <pre><code>Criteria criteria = session.createCriteria(Employee.class);
  criteria.createAlias("company", "company");
  criteria.add(Restrictions.like("company.companyName ", "xxxx%"));
  return criteria.list();
  </code></pre>
  
  <p>But i get the error:</p>
  
  <pre><code>could not resolve property: company.companyName of: Employee
  </code></pre>
  
  <p>Where is the problem in this code?</p>