title: Hibernate. Optimizing sqlRestriction
body: <p>How can I optimize the following without sqlRestriction:</p>
  
  <pre><code>public List&lt;SomeEntity&gt; getEntityByYearMonthAndDay(Calendar cal) {
          Criteria criteria = helper.createCriteria();
          criteria.add(sqlRestriction("(DATE(date_column) = ?)", cal.getTime(), org.hibernate.type.StandardBasicTypes.DATE));
          return criteria.list();
  }
  </code></pre>
  
  <p>SomeEntity looks like:</p>
  
  <pre><code>    @Entity
      @Table(name="some_table")
      public class SomeEntity extends Identifiable {
  
  
          @Column(name = "date_column")
          private Calendar dateColumn;
  
  //Getters and setters 
      }
  </code></pre>
  
  <p>In the DB I have such representation:
  date_column => datetime (YYYY-MM-DD HH:mm:ss).</p>
  
  <p>It's obvious that logic compares only date truncating time values.</p>