/*
 * 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.DetalleAbonos;

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 DetalleAbonosFacade extends AbstractFacade<DetalleAbonos> implements DetalleAbonosFacadeLocal {
    @PersistenceContext(unitName = "wcosmodasPersistent")
    private EntityManager em;

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

    public DetalleAbonosFacade() {
        super(DetalleAbonos.class);
    }

    @Override
    public List<DetalleAbonos> obternerDetalles(String abonoCodigo, String abonoTipo) {
        Query q = em.createNamedQuery("DetalleAbonos.findByAbonoCodigoAndAbonoTipo");
        q.setParameter("abonoCodigo", abonoCodigo);
        q.setParameter("abonoTipo", abonoTipo);

        return q.getResultList();
    }

    @Override
    public void nuevo(DetalleAbonos detalle) {

        em.merge(detalle);

    }


}
