Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("FROM Employee"); ListemployeeList = query.list();
Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("FROM Employee WHERE salary > :salary"); query.setParameter("salary", 50000); ListemployeeList = query.list();
Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("SELECT COUNT(*) FROM Employee"); Long count = (Long) query.list().get(0);This code snippet retrieves the count of all records from the Employee table and stores it as a Long value.