title: Hibernate CriteriaQuery How to Find list of integer having two conditions
body: <p>I got two entity class one:</p>
  
  <pre><code>@Table(name = "package")
  public class Package {
  
  
      @Id
      @Column(name = "package_id", insertable = false, nullable = false)
      private Long packageId;
  
      @Column(name = "timestamp", nullable = false, updatable = false)
      @Temporal(TemporalType.TIMESTAMP)
      private Date timestamp;
  
      @Column(name = "name", nullable = false)
      private String name;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "queue_id",foreignKey=@ForeignKey(name = "package_queue_id_fk"))
      private Queue Queue;
  
  @Column(name = "file_number", nullable = true)
  private Integer fileNumber;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>@Table(name = "queue")
  public class Queue {
  
      @Id
      @Column(name = "queue_id", insertable = false, nullable = false)
      private Integer queue;
  
      @Column(name = "description", nullable = true)
      private String description;
  
      @Column(name = "name", nullable = false)
      private String name;
  
      @OneToMany(mappedBy = "Queue", fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.REFRESH })
      @MapKeyColumn(name = "package_id")
      private Set&lt;Package&gt; packages;
  </code></pre>
  
  <p>And I would like to find List of fileNumbers depending on package.name and package.queue.queue_id</p>
  
  <p>So currently I got only one condition (name) and it looks like this:</p>
  
  <pre><code>public List&lt;Integer&gt; getAllFileNumbers(String fileName, Integer queueId) {
  
      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery&lt;Integer&gt; query = cb.createQuery(Integer.class);
  
      Root&lt;Package&gt; package = query.from(package.class);
      query.select(package.get("fileNumber")).where(cb.equal(package.get("name"), fileName));
  
      return em.createQuery(query).getResultList();
  }
  </code></pre>
  
  <p>Anyone could help me add another one, on top of thet remamber that the value need to be from another entity.</p>
  
  <p>Edit:</p>
  
  <p>So after @Leviand hint I did it like this:</p>
  
  <pre><code>        Predicate filenamePred= cb.equal(package.get("name"), fileName);
          Predicate queueIdPred = cb.equal(package.get("queue_id"), queueId);
  
          query.select(package.get("fileNumber")).where(cb.and(filenamePred, queueIdPred ));
  </code></pre>
  
  <p>I got error:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: Unable to locate Attribute  with the the given name [queue_id] on this ManagedType 
  </code></pre>