title: Spring JPA criteria builder greaterThan : Can I pass String value for comparing Number type in database
body: <p>I am using Spring Data JPA criteria builder <code>greaterThan</code> API for doing a comparison.</p>
  <p>The database field <code>rating</code> is of type <code>NUMBER(5,0)</code>. Entity class has a field <code>rating</code> which is of type <code>Integer</code>. And I am passing the value of type <code>String</code> for the comparison.</p>
  <p>Even though I am not passing the <code>Integer</code> value for the comparison, still it is returning valid results. Please help me understand how this is possible.</p>
  <p>Does it mean, I can pass the java <code>String</code> version of the database field to the greaterThan method when the actual data type of the field in the database is of a different type.</p>
  <p>and my comparison block of code looks like this</p>
  <pre><code>CriteriaBuilder cb = entityManager.getCriteriaBuilder();
  
  CriteriaQuery cq = cb.createQuery();
  
  Root&lt;Customer&gt; root = cq.from(Customer.class);
  //you can see here , value 20 I am passing as String
  Predicate comparisonPredicate = cb.greaterThan(root.get(&quot;rating&quot;), &quot;20&quot;);
  
  cq.where(comparisonPredicate );
  
  cq.select(root);
  
  TypedQuery&lt;Customer&gt; query = entityManager.createQuery(cq);
  </code></pre>