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

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

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

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

    public RegaloFacade() {
        super(Regalo.class);
    }

    @Override
    public Regalo BusquedaId(int idRegalo) {
        Query q = em.createNamedQuery("Regalo.findById");
        q.setParameter("id", q);

        return (Regalo) q.getResultList().get(0);
    }

    @Override
    public Regalo porSucursal(String sucursalCodigo) {
        Query q = em.createNamedQuery("Regalo.findBySucursal");
        q.setParameter("sucursal", sucursalCodigo);

        return (Regalo) q.getResultList().get(0);
    }


}
