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

package inventario.facade;


import inventario.facade.remote.SupplierFacadeRemote;
import inventario.entity.Supplier;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Daniel
 */
@Stateless
public class SupplierFacade implements  SupplierFacadeRemote {
    @PersistenceContext
    private EntityManager em;

    public void create(Supplier supplier) {
        em.persist(supplier);
    }

    public void edit(Supplier supplier) {
        em.merge(supplier);
    }

    public void remove(Supplier supplier) {
        em.remove(em.merge(supplier));
    }

    public Supplier find(Object id) {
        return em.find(Supplier.class, id);
    }

    public List<Supplier> findAll() {
        return em.createQuery("select object(o) from Supplier as o").getResultList();
    }

}
