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

package inventario.facade;


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

/**
 *
 * @author Daniel
 */
@Stateless
public class CategoryFacade implements  CategoryFacadeRemote {
    @PersistenceContext
    private EntityManager em;

    public void create(Category category) {
        em.persist(category);
    }

    public void edit(Category category) {
        em.merge(category);
    }

    public void remove(Category category) {
        em.remove(em.merge(category));
    }

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

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

}
