title: Hibernate Criteria Return parent record that have one-to-one child record not null?
body: <p>I have a one-to-one relation like this </p>
  
  <p>The Parent </p>
  
  <pre><code>@JsonAutoDetect
  @Entity
  @Table(name = "Parent")
  public class Parent{
  
      private Integer id;
      private Child child;
  
      @Id
      @GeneratedValue(strategy= GenerationType.AUTO)
      @Column (name="idparent")
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }
  
      @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "parent")
      @JoinColumn(name="idchild", nullable=true)
      public Child getChild() {
          return child;
      }
      public void setChild(Child child) {
          child.setParent(this);
          this.child = child;
      }
  }
  </code></pre>
  
  <p>and the child</p>
  
  <pre><code>@JsonAutoDetect
  @Entity
  @Table(name="Child")
  public class Child{
  
      private Integer id;
      private Parent parent;
  
      @Id
      @GeneratedValue(generator = "foreign")
      @GenericGenerator(name = "foreign", strategy = "foreign", parameters = { @Parameter(name = "property", value = "parent") })
      @Column (name = "idchild")
      public Integer getId() {
          return id;
      }
      public void setId(Integer id) {
          this.id = id;
      }
  
      @OneToOne(fetch = FetchType.LAZY, optional = true)
      @Cascade({ org.hibernate.annotations.CascadeType.SAVE_UPDATE })
      @PrimaryKeyJoinColumn
      @JsonIgnore
      public Parent getParent() {
          return parent;
      }
      public void setParent(Parent parent) {
          this.parent= parent;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I want to create criteria that return the parent that have child isNotNull, i tryed somme think like</p>
  
  <pre><code>Criteria criteria = session.createCriteria(Parent.class);
  criteria.add(Restrictions.isNotNull("child"));
  </code></pre>
  
  <p>But not work, can  you help me by giving somme example please ? Thanks</p>