How to write query in Hibernate SQL
or HSQL
to show one week data or 1month data from current date?
Asked
Active
Viewed 613 times
1 Answers
0
Consider an Entity Product with _productId and _productCreatedDate So the
StringBulider sql=new StringBuilder();
sql.append("select _productId,_productCreatedDate from Product where");
sql.append("_productCreatedDate between :currentDate and :dateOneMonthBefore")
sessionFactory.getSession().createQuery(sql.toString()).setParameter("currentDate",newDate())
.setParameter("dateOneMonthBefore",new Date("Enter the month before the current date"))

BholaVishwakarma
- 581
- 6
- 18