package hr.przyklady;

import java.util.List;

import hr.model.Employee;
import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;
import jakarta.persistence.TypedQuery;

public class OdczytajWszystkich2 {

	public static void main(String[] args) {
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("hr");
		EntityManager em = emf.createEntityManager();
	
		TypedQuery<Employee> query = em.createNamedQuery("Employee.findAll", Employee.class);

		List<Employee> lista = query.getResultList();
		for(Employee emp : lista) {
			System.out.println(emp.getFirstName() + " " + emp.getLastName() + " " + emp.getSalary() + " zatr. " + emp.getHireDate());
		}
		
		em.close();
		emf.close();
	}

}
