Code example for SessionFactory

Methods: openSession

0
	 
	 
 
	private static List list() {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();
 
		List employees = session.createQuery("from Employee").list();
		session.close();
		return employees;
	} 
	private static Employee read(Long id) {
		SessionFactory sf = HibernateUtil.getSessionFactory();
		Session session = sf.openSession();
 
		Employee employee = (Employee) session.get(Employee.class, id);
		session.close();
		return employee;
	} 
	private static Employee save(Employee employee) {
Experience pair programming with AI  Get Codota for Java