package sklep.przyklady_hibernate;

import jakarta.persistence.EntityManager;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;

import sklep.model.Product;

public class OdczytajJedenProdukt_v0 {

	public static void main(String[] args) {
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("sklep");
		EntityManager em = emf.createEntityManager();
		System.out.println("Mam EntityManagera: " + em);
		
		Product product = em.find(Product.class, 2);
		System.out.println("Mam obiekt: " + product);
		System.out.println(product.getProductName() + " za cenę " + product.getPrice());

		em.close();
		emf.close();
	}

}
