Commit 9fd90ca1 by Patryk Czarnik

Program P1

parent 98bf3907
package sklep.przyklady;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import sklep.model.Product;
public class P1_OdczytajJedenProdukt {
public static void main(String[] args) {
System.out.println("Startujemy...");
EntityManagerFactory emf = Persistence.createEntityManagerFactory("sklep");
EntityManager em = emf.createEntityManager();
System.out.println("Udało się połączyć. em = " + em);
Product product = em.find(Product.class, 1);
System.out.println("Odczytałem produkt nr 1: " + product);
System.out.println(product.getProductName() + " za cenę " + product.getPrice());
em.close();
emf.close();
System.out.println("Koniec...");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment