Information

0
Story Points

Technologies

Decompiled Java File
package mx.com.bcm.banamex.ae.persistencia.dao.impl;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import mx.com.bcm.banamex.ae.persistencia.common.GlobalJpaDaoBean;
import mx.com.bcm.banamex.ae.persistencia.constantes.OperadorLogicoType;
import mx.com.bcm.banamex.ae.persistencia.dao.CatalogoCuentaDAOBeanLocal;
import mx.com.bcm.banamex.ae.persistencia.exception.EfectivoAplicacionDAOException;
import mx.com.bcm.banamex.ae.persistencia.helper.UtileriaHelper;
import mx.com.bcm.banamex.ae.persistencia.modelo.Cuenta;
import mx.com.bcm.banamex.ae.persistencia.modelo.CuentaPK;
import mx.com.bcm.banamex.ae.persistencia.vo.CriteriaCuentaVO;

@Stateless
public class CatalogoCuentaDAOImplBeanLocal extends GlobalJpaDaoBean implements CatalogoCuentaDAOBeanLocal {
   @PersistenceContext
   private EntityManager em;

   public List consultaCuentaPorid(CuentaPK cuentaPK) throws EfectivoAplicacionDAOException {
      List listaCuenta = null;
      TypedQuery query = this.em.createNamedQuery("Cuenta.findByUnegId", Cuenta.class);
      query.setParameter("unegId", Short.valueOf(cuentaPK.getUnegId()));
      listaCuenta = query.getResultList();
      return listaCuenta;
   }

   public List consultaCuentaParametrizada(CriteriaCuentaVO criteriaCuentaVO) throws EfectivoAplicacionDAOException {
      StringBuilder query = new StringBuilder();
      String queryFormateado = UtileriaHelper.getFiltroDeAtributos(criteriaCuentaVO.toString(), OperadorLogicoType.AND, 'c');
      if(queryFormateado.equals("")) {
         new StringBuilder();
         new String();
         return this.consultaCuenta();
      } else {
         query.append(" SELECT c FROM Cuenta c JOIN FETCH c.divisaId ");
         query.append(" WHERE " + queryFormateado);
         TypedQuery criteria = this.em.createQuery(query.toString(), Cuenta.class);
         new StringBuilder();
         return criteria.getResultList();
      }
   }

   public List consultaCuenta() throws EfectivoAplicacionDAOException {
      StringBuilder query = new StringBuilder();
      query.append(" SELECT c FROM Cuenta c JOIN FETCH c.divisaId ");
      TypedQuery criteria = this.em.createQuery(query.toString(), Cuenta.class);
      new StringBuilder();
      return criteria.getResultList();
   }
}
Page generated: Oct 19, 2017 2:35:21 PM