title: Hibernate criteria query not respecting multiple restrictions
body: <p>I am trying to query 2 tables using criteria. Below is the method:</p>
  
  <pre><code>   public UserEntity getUserOverView(long userId, String receiptMonth) {
  
    Session session = HibernateUtil.getSessionFactory().openSession();
     UserEntity user = new UserEntity();
  
    try {
       session.beginTransaction();
  
            Criteria criteria = session.createCriteria(UserEntity.class, "user")
             .createAlias("user.receiptEntitySet", "receipt")
             .add(Restrictions.eq("receipt.dateCreated", receiptMonth))
             .add(Restrictions.eq("user.userId", userId));
  
  
       user = (UserEntity) criteria.uniqueResult();
  
    } catch (Exception ex) {
  
       System.out.print(ex.getMessage());
    } finally {
  
       session.getTransaction().commit();
       session.close();
  
    }
  
    return user;
  </code></pre>
  
  <p>}</p>
  
  <p>The above is successfully respecting the userId, however, I want to filter on the 'receiptMonth' in the other table. It seems to be ignoring the 'receiptMonth' restriction completely.</p>
  
  <p>UserEntity:</p>
  
  <pre><code>    package za.co.skizzel.infrastructure.entities;
  
  import javax.persistence.*;
  import java.util.Set;
  
  @Entity
  @Table(name="user")
  public class UserEntity {
  
    @Id
    @GeneratedValue
    @Column(name="userId", unique = true, nullable = false, updatable = false )
    private Long userId;
  
    @Column(name="email")
    private String email;
  
    @Column(name="password")
    private String password;
  
    @Column(name="name")
    private String name;
  
    @OneToMany(fetch = FetchType.EAGER, mappedBy = "userEntity" , cascade = { CascadeType.ALL } )
    private Set&lt;ReceiptEntity&gt; receiptEntitySet;
  
     @OneToMany(fetch = FetchType.EAGER, mappedBy = "userEntity" , cascade = { CascadeType.ALL } )
     private Set&lt;CategoryEntity&gt; categoryEntitySet;
  
     public Set&lt;CategoryEntity&gt; getCategoryEntitySet() {
        return categoryEntitySet;
     }
  
     public void setCategoryEntitySet(Set&lt;CategoryEntity&gt; categoryEntitySet) {
        this.categoryEntitySet = categoryEntitySet;
     }
  
     public Long getUserId() {
        return userId;
     }
  
     public void setUserId(Long userId) {
        this.userId = userId;
     }
  
     public String getEmail() {
        return email;
     }
  
     public void setEmail(String email) {
        this.email = email;
     }
  
     public String getPassword() {
        return password;
     }
  
     public void setPassword(String password) {
        this.password = password;
     }
  
     public String getName() {
        return name;
     }
  
     public void setName(String name) {
        this.name = name;
     }
  
     public Set&lt;ReceiptEntity&gt; getReceiptEntitySet() {
        return receiptEntitySet;
     }
  
     public void setReceiptEntitySet(Set&lt;ReceiptEntity&gt; receiptEntitySet) {
        this.receiptEntitySet = receiptEntitySet;
     }
  
     public UserEntity(){};
  
     public UserEntity(long userId){
        this.userId = userId;
     };
  
  }
  </code></pre>
  
  <p>ReceiptEntity:</p>
  
  <pre><code>    package za.co.skizzel.infrastructure.entities;
  
  
  import javax.persistence.*;
  import java.util.Set;
  
  @Entity
  @Table(name="receipt")
  public class ReceiptEntity {
  
    @Id
    @GeneratedValue
    @Column(name="ReceiptId", unique = true, nullable = false, updatable = false )
    private Long receiptId;
  
    @Column(name="alias")
    private String alias;
  
     @Column(name="categoryId")
     private long categoryId;
  
    @Column(name="DateCreated")
    private String dateCreated;
  
    @ManyToOne
    @JoinColumn(name="userId", nullable=false, insertable = false, updatable = false)
    private UserEntity userEntity;
  
     @OneToMany(fetch = FetchType.EAGER, mappedBy = "receiptEntity" , cascade = { CascadeType.ALL } )
     private Set&lt;ImageEntity&gt; imageEntitySet;
  
     private long userId;
  
     public long getUserId() {
        return userId;
     }
  
     public void setUserId(long userId) {
        this.userId = userId;
     }
  
     public long getCategoryId() {
        return categoryId;
     }
  
     public void setCategoryId(long categoryId) {
        this.categoryId = categoryId;
     }
  
     public Long getReceiptId() {
      return receiptId;
    }
  
    public void setReceiptId(Long receiptId) {
      this.receiptId = receiptId;
    }
  
    public String getAlias() {
      return alias;
    }
  
    public void setAlias(String alias) {
      this.alias = alias;
    }
  
    public String getDateCreated() {
      return dateCreated;
    }
  
    public void setDateCreated(String dateCreated) {
      this.dateCreated = dateCreated;
    }
  
    public UserEntity getUserEntity() {
      return userEntity;
    }
  
    public void setUserEntity(UserEntity userEntity) {
      this.userEntity = userEntity;
    }
  
     public ReceiptEntity() {};
  
  }
  </code></pre>
  
  <p>Not sure what I am doing wrong? Any guidance would be appreciated?</p>
  
  <p>Thanks
  Luke</p>
  
  <p>EDIT</p>
  
  <p>I am expecting something like:</p>
  
  <pre><code>select * from user, receipt where user.userId = '8' and receipt.dateCreated = 'January 2014'
  </code></pre>