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

import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Administrator
 */
@Stateless
@LocalBean
public class NoticeFacade {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @PersistenceContext
    private EntityManager em;
    
    /** Creates a new instance of NoticeFacade */
    public NoticeFacade() {
    }

    public void create(Notice notice) {
        em.persist(notice);
    }

    public void edit(Notice notice) {
        em.merge(notice);
    }

    public void destroy(Notice notice) {
        em.merge(notice);
        em.remove(notice);
    }

    public Notice find(Object pk) {
        return (Notice) em.find(Notice.class, pk);
    }

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