Example usage for javax.persistence NonUniqueResultException printStackTrace

List of usage examples for javax.persistence NonUniqueResultException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:net.o3s.beans.registering.RegisteringBean.java

/**
  * Get registered from label/*from  ww  w. j  av a 2s .  c  o  m*/
  */
 public IEntityRegistered findRegisteredFromLabel(final String labelValue) throws InvalidException {
     Query query = this.entityManager.createNamedQuery("REGISTERED_FROM_LABEL");
     IEntityEvent event = admin.findDefaultEvent();
     query.setParameter("EVENTID", event.getId());
     query.setParameter("VALUE", labelValue);

     IEntityRegistered registered = null;
     try {

         registered = (IEntityRegistered) query.getSingleResult();
     } catch (javax.persistence.NoResultException nre) {

     } catch (NonUniqueResultException nure) {
         nure.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard [" + labelValue + "]", nure);
     } catch (Exception e) {
         e.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard [" + labelValue + "]", e);

     }

     return registered;

 }

From source file:net.o3s.beans.registering.RegisteringBean.java

/**
  * Get registered from rfid tag//from ww w.j a v  a2 s. c o  m
  */
 public IEntityRegistered findRegisteredFromRfid(final String rfid) throws InvalidException {
     Query query = this.entityManager.createNamedQuery("REGISTERED_FROM_RFID");
     query.setParameter("RFID", rfid);
     IEntityEvent event = admin.findDefaultEvent();
     query.setParameter("EVENTID", event.getId());

     IEntityRegistered registered = null;
     try {

         registered = (IEntityRegistered) query.getSingleResult();
     } catch (javax.persistence.NoResultException nre) {

     } catch (NonUniqueResultException nure) {
         nure.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard avec pour tag rfid [" + rfid + "]", nure);
     } catch (Exception e) {
         e.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard avec pour tag rfid  [" + rfid + "]", e);

     }

     return registered;

 }

From source file:net.o3s.beans.registering.RegisteringBean.java

/**
  * Get registered from labelNumber/*from w  ww. j  a  v a  2  s . com*/
  */
 public IEntityRegistered findRegisteredFromLabelNumber(final int labelNumber) throws InvalidException {
     Query query = this.entityManager.createNamedQuery("REGISTERED_FROM_LABELNUMBER");
     IEntityEvent event = admin.findDefaultEvent();
     query.setParameter("EVENTID", event.getId());
     query.setParameter("VALUE", labelNumber);

     IEntityRegistered registered = null;
     try {

         registered = (IEntityRegistered) query.getSingleResult();
     } catch (javax.persistence.NoResultException nre) {

     } catch (NonUniqueResultException nure) {
         nure.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard [" + labelNumber + "]", nure);
     } catch (Exception e) {
         e.printStackTrace();
         throw new InvalidException("Impossible de trouver ce dossard [" + labelNumber + "]", e);

     }

     return registered;

 }