Query query = session.createQuery("from Employee where hireDate > :date"); Date date = new Date(); query.setDate("date", date); Listemployees = query.list();
Query query = session.createQuery("from Order where dateCreated > :date"); Calendar date = Calendar.getInstance(); date.set(2021, Calendar.OCTOBER, 1); // set the date to October 1st, 2021 query.setDate("date", date.getTime()); ListIn this example, a query is created to retrieve all orders that were created after a specific date. The setDate method is used to set the date parameter in the query using a Calendar object. Package library: org.hibernate.orders = query.list();