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