/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

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

/**
 *
 * @author Hoss
 */
@Stateless
@LocalBean
public class CustomerManager {
    @PersistenceContext(unitName = "CustomerApp-ejbPU")
    private EntityManager em;
    
    public Customer getCustomer(int idCustomer) {
        return em.find(Customer.class, idCustomer);
         }
    public List<Customer> getAllCustomers() {
        Query query=em.createNamedQuery("Customer.findAll");
        return query.getResultList();
    }

    public Customer update(Customer c) {
        return em.merge(c);
    }

    public void Add(Customer c) {
        em.persist(c);    
    }

    
        
}
