Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from Person"); Listpeople = query.list();
Session session = HibernateUtil.getSessionFactory().openSession(); Query query = session.createQuery("from Person where age > :age"); query.setParameter("age", 18); Listadults = query.list();
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.Query; import org.hibernate.cfg.Configuration;