Date range query on Timestamp field in HQL
Suppose we want to make query between two dates in a timestamp field for example We have a table colors to store different colors
1 2 3 4 5 6 | create table colors( color_id bigint(10)NOT NULL AUTO_INCREMENT, color varchar(50), add_date timestamp DEFAULT 0, status varchar(20), primary Key(color_id)); |
Pojo class for color table is
1 2 3 4 5 6 | public class Color implements java.io.Serializable { private Long colorId; private String color; private Timestamp addDate; private String status; //getter setter and constructor |
Above class shows that addDate is timestamp field and we want to query it as date for that we have casted timestamp field … Read more