/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.glassfish.samples;

import java.util.List;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.glassfish.samples.model.Product;

/**
 *
 * @author SOLA
 */
@Named
@Stateless
public class ProductEJB {
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @PersistenceContext
    @Inject Product product;
    EntityManager em;

    public List getList() {

        return em.createNamedQuery("Product.findAll").getResultList();
    }
  public void create() {

        Product p2 = new Product(product.getId(),product.getName(),product.getQuantity());
        em.persist(p2);
    }
 
}
