title: Hibernate UniDirectional ManyToOne query by child's property
body: <pre><code>@Entity
  public class Store {}
  
  
  @Entity
  @Table(name = "storeitem")
  public class StoreItem {
  
      @Id @Column
      private Integer storeId;
  
      @Id
      @ManyToOne @JoinColumn (name="productId", referencedColumnName="id")
      private Product product;
  
      @Column private Double cost;
  }
  
  mysql&gt; desc storeitem;
  +-------------+---------------------+------+-----+---------+-------+
  | Field       | Type                | Null | Key | Default | Extra |
  +-------------+---------------------+------+-----+---------+-------+
  | StoreId     | int(10) unsigned    | NO   | PRI | 0       |       |
  | ProductId   | bigint(20) unsigned | NO   | PRI | 0       |       |
  | cost        | double unsigned     | NO   |     | 0       |       |
  
  
  
  @Entity
  @Table(name = "product")
  public class Product {
      @Id @GeneratedValue @Column(name = "Id")
      private Long id;
  
      @Column(name = "Name")
      private String name;
  }
  
  mysql&gt; desc product;
  +-------------+---------------------+------+-----+---------+----------------+
  | Field       | Type                | Null | Key | Default | Extra          |
  +-------------+---------------------+------+-----+---------+----------------+
  | Id          | bigint(20) unsigned | NO   | PRI | NULL    | auto_increment |
  | Name        | varchar(70)         | NO   |     |         |                |
  
  
  
  
   Criteria cr=sess.createCriteria(StoreItem.class);
   cr.add(Restrictions.eq("product.name","butter"));
   cr.list();
  </code></pre>
  
  <p>When i try to filter by child's property i get this below exception</p>
  
  <pre><code>org.hibernate.QueryException: could not resolve property: product.name of:StoreItem
  </code></pre>