Exemple #1
0
  public static void main(String[] args) {

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("nwind-pu");
    EntityManager em = emf.createEntityManager();

    int id = 2;
    Supplier supp = em.find(Supplier.class, id);

    System.out.println("Supplier Id:" + supp.getSupplierId());
    System.out.println("Supplier Name:" + supp.getCompanyName());
    System.out.println("Products in this category are");
    for (Product p : supp.getProducts()) {
      System.out.println("\t" + p.getProductName());
    }
  }