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

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

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

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

    public ConsultoresDatosFacade() {
        super(ConsultoresDatos.class);
    }

    @Override
    public ConsultoresDatos DatosDeConsultor(String consultorCodigo) {
        ConsultoresDatos rs;
        try {
            Query q = em.createNamedQuery("ConsultoresDatos.findByConsultorCodigo");
            q.setParameter("consultorCodigo", consultorCodigo);
            rs = (ConsultoresDatos) q.getResultList().get(0);
        } catch (Exception e) {
            rs = new ConsultoresDatos();
        }
        return rs;
    }


}
