package sklep.przyklady;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import sklep.model.Product;

public class OdczytajJedenProdukt1 {

	public static void main(String[] args) {
		System.out.println("Początek programu");
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("sklep");
		EntityManager em = emf.createEntityManager();
		
		System.out.println("Mam entity managera: " + em);
		
		Product product = em.find(Product.class, 1);
		System.out.println("Odczytany produkt: " + product);
		System.out.println(product.getProductName() + " za cenę " + product.getPrice() + ", opis: " + product.getDescription());
		
		em.close();
		emf.close();
	}

}
