package com.cosmodas.FacadeCosmos;

import com.cosmodas.EntCosmos.VPedidosApps;

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

@Stateless
public class VPedidosAppsFacade extends AbstractFacade<VPedidosApps> implements VPedidosFacadeAppsLocal{

    @PersistenceContext(unitName = "wcosmodasPersistent")
    private EntityManager em  ;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public VPedidosAppsFacade() {
        super(VPedidosApps.class);
    }

    @Override
    public List<VPedidosApps> pedidosPorMes(String programaCodigo){

        List<VPedidosApps> rs = new ArrayList<>();

        Query q = em.createNativeQuery("CALL obtener_pedidos_apps(?)", VPedidosApps.class);
        q.setParameter(1, programaCodigo);

        rs.addAll(q.getResultList());

        return rs;
    }

}
