Example usage for javax.persistence NoResultException printStackTrace

List of usage examples for javax.persistence NoResultException printStackTrace

Introduction

In this page you can find the example usage for javax.persistence NoResultException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.gerenciaProyecto.DaoImple.UsuarioDaoImpl.java

@Override
public Usuario consultaUsuarioLogin(String login) {
    EntityManager em = getEntityManager();
    Usuario usuarioLogin = null;/*ww w  .j  a va 2 s .  co  m*/
    try {
        Query q = em.createQuery("SELECT u FROM Usuario u WHERE u.username = :username");
        q.setParameter("username", login);
        usuarioLogin = (Usuario) q.getSingleResult();
    } catch (NoResultException e) {
        e.printStackTrace();
    }
    return usuarioLogin;
}

From source file:com.cimpoint.mes.server.repositories.StepStatusRepository.java

public EStepStatus findStepStatusByName(String stepStatusName) {
    try {/*from   ww  w  .  j  av  a2s. co m*/
        Query qry = getEntityManager().createQuery("select o from EStepStatus o where o.name = ?1")
                .setParameter(1, stepStatusName).setMaxResults(1);
        EStepStatus step = (EStepStatus) qry.getSingleResult();
        return step;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:com.cimpoint.mes.server.repositories.TravelerRepository.java

public ETraveler findTravelerByWorkOrderNumber(String workOrderNumber) throws Exception {
    try {/* w  w w  . j  a  v a2 s . com*/
        ETraveler traveler = (ETraveler) getEntityManager()
                .createQuery("select o from ETraveler o where o.workOrderNumber = ?1")
                .setParameter(1, workOrderNumber).getSingleResult();
        return traveler;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.TransitionAttributesRepository.java

public ETransitionAttributes findTransitionAttributes(long objectId, MESConstants.Object.Type objectType) {
    try {//from   w  w  w .  j a  va  2  s .  c o  m
        Query qry = entityManager
                .createQuery("select o from " + ETransitionAttributes.class.getName()
                        + " o where o.objectId = ?1 AND o.objectType = ?2")
                .setParameter(1, objectId).setParameter(2, objectType);
        ETransitionAttributes e = (ETransitionAttributes) qry.getSingleResult();
        return e;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:com.cimpoint.mes.server.repositories.TransitionRepository.java

public ETransition findTransitionByName(String routingName, String transitionName) {
    try {/*from   ww  w  .j av a  2s. c  o m*/
        Query qry = getEntityManager()
                .createQuery("select o from ETransition o where o.routingName = ?1 and o.name = ?2")
                .setParameter(1, routingName).setParameter(2, transitionName).setMaxResults(1);
        ETransition trsn = (ETransition) qry.getSingleResult();
        return trsn;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:com.cimpoint.mes.server.repositories.RecipeRepository.java

public ERecipe findRecipeByName(String equipmentName) throws Exception {
    try {/* w  w  w . j  av a 2  s  . co m*/
        ERecipe equipment = (ERecipe) getEntityManager()
                .createQuery("select o from ERecipe o where o.number = ?1").setParameter(1, equipmentName)
                .getSingleResult();
        return equipment;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.RecipeRepository.java

public EComponent findComponentByNameAndRevision(String componentName, String componentRevision)
        throws Exception {
    try {//from ww w .  j a v  a  2 s.c om
        EComponent c = (EComponent) getEntityManager()
                .createQuery("select o from EComponent o where o.name = ?1 and o.revision = ?2")
                .setParameter(1, componentName).setParameter(2, componentRevision).getSingleResult();
        return c;
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.BomRepository.java

public EBom findBomByNameAndRevision(String name, String revision) throws Exception {
    try {//from ww  w .j a v  a 2  s  .  c  om
        return (EBom) getEntityManager()
                .createQuery("select o from EBom o where o.name = ?1 and o.revision = ?2").setParameter(1, name)
                .setParameter(2, revision).getSingleResult();
    } catch (NoResultException ex) {
        return null;
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.BatchRepository.java

@SuppressWarnings("unchecked")
public Set<EBatch> findBatchesByWorkOrderNumber(String workOrderNumber) throws Exception {
    try {//from  w  w w  .j av  a2  s  . c  o  m
        Set<EBatch> list = (Set<EBatch>) getEntityManager()
                .createQuery("select o from EBatch o where o.workOrderNumber = ?1")
                .setParameter(1, workOrderNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new HashSet<EBatch>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.cimpoint.mes.server.repositories.BatchRepository.java

@SuppressWarnings("unchecked")
public List<String> findBatchsByWorkOrderItemNumber(String workOrderItemNumber) throws Exception {
    try {/*ww w .j a v a2s .  c  om*/
        List<String> list = (List<String>) getEntityManager()
                .createQuery("select o.number from EBatch o where o.workOrderItemNumber = ?1")
                .setParameter(1, workOrderItemNumber).getResultList();
        return list;
    } catch (NoResultException ex) {
        return new ArrayList<String>();
    } catch (Exception ex) {
        ex.printStackTrace();
        throw ex;
    }
}