title: Trying to implement a criteria query using Hibernate, getting "cannot resolve method" error
body: <p>I have a table with the following columns and the corresponding POJO class</p>
  <pre><code>@Entity
  @Table(name = &quot;base_quote&quot;)
  public class BaseQuote {
  
  @Id
  @Column(name = &quot;id&quot;)
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private int id;
  
  @Column(name = &quot;cc_min&quot;)
  private int cubicCapacityMin;
  
  @Column(name = &quot;cc_max&quot;)
  private int cubicCapacityMax;
  
  @Column(name = &quot;car_age_min&quot;)
  private int carAgeMin;
  
  @Column(name = &quot;car_age_max&quot;)
  private int carAgeMax;
  
  @Column(name = &quot;base_amount&quot;)
  public double baseAmount;
  </code></pre>
  <p>constructor, getters and setters</p>
  <p>I am trying to write a query that will return the baseAmount for a car, the cubic capacity of which is between cc_min and cc_max and age is between carAgeMin and carAgeMax.  I am trying to get either the entire row so I can later use the baseAmount of that row.</p>
  <p>I am receiving the cc and age of the car trough a DTO.</p>
  <pre><code>private double baseAmount (QuoteDTO quoteDTO) {
      try (Session session = sessionFactory.openSession()) {
  
          CriteriaBuilder cb = session.getCriteriaBuilder();
          CriteriaQuery&lt;BaseQuote&gt; cq = cb.createQuery(BaseQuote.class);
          Root&lt;BaseQuote&gt; root = cq.from(BaseQuote.class);
          cq.select(root).where(cb.gt(root.get(&quot;cc_max&quot;)), quoteDTO.getCubicCapacity());
  
          Query&lt;BaseQuote&gt; query = session.createQuery(cq);
          List&lt;BaseQuote&gt; results = query.getResultList();
        
      }
      
      return null;
  }
  </code></pre>
  <p>I am getting something wrong because  I get cannot resolve method for <code>cb.gt(root.get(&quot;cc_max&quot;)</code> I tried also using the class field name <code>cubicCapacityMax</code> instead of <code>cc_max</code>, but I an getting the same error. I want to get the rows in which the  <code>cc_max</code> is greater than the DTO cubic capacity, so I used the <code>.gt()</code> as proposed in the demo I was using.  It underlines everything in the brackets of the <code>.gt()</code>. I know that this does not produce the specific result I am actually looking for, but it is the first part of the expression.  Where am I wrong?
  <a href="https://i.stack.imgur.com/Fi0RC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fi0RC.png" alt="enter image description here" /></a></p>