/*
 * 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 com.cosmodas.FacadeCosmos;

import com.cosmodas.EntCosmos.DetallePremio;

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

/**
 * @author obper
 */
@Stateless
public class DetallePremioFacade extends AbstractFacade<DetallePremio> implements DetallePremioFacadeLocal {
    @PersistenceContext(unitName = "wcosmodasPersistent")
    private EntityManager em;

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

    public DetallePremioFacade() {
        super(DetallePremio.class);
    }

    @Override
    public List<DetallePremio> detallePremio(String premioCodigo) {
        List<DetallePremio> dtp;
        System.out.println("premio Codigo = " + premioCodigo);
        try {
            Query q = em.createNamedQuery("DetallePremio.findByPremioCodigo");
            q.setParameter("premioCodigo", premioCodigo);
            dtp = q.getResultList();

        } catch (Exception e) {
            dtp = new ArrayList<>();
        }
        return dtp;
    }


}
